473,383 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Why can I not assign method group to implicity -typed local variable?

103 100+
I created a class with a simple string return method
Expand|Select|Wrap|Line Numbers
  1.   public class Printer
  2.     {
  3.         public string GetPrinterName()
  4.         {
  5.             return "HP 540P";
  6.         }
  7.  

WHEN I try to call the method on a button_click event, I get an error "Cannot assign method group to an implicity-typed local varaible" which in this case is the var result.

Expand|Select|Wrap|Line Numbers
  1.      private void button1_Click(object sender, RoutedEventArgs e)
  2.         {     
  3.             var p = new Printer();
  4.             var result = p.GetPrinterName;
  5.             var isReady = Printer.IsPrinterReady(result);
  6.  
  7.             MessageBox.Show(String.Format("Is the Printer ready: {0}", isReady));

Can you share light and help me?
Jun 25 '12 #1

✓ answered by PsychoCoder

I believe this line:

Expand|Select|Wrap|Line Numbers
  1. var result = p.GetPrinterName;
Should be:

Expand|Select|Wrap|Line Numbers
  1. var result = p.GetPrinterName();

1 6789
PsychoCoder
465 Expert Mod 256MB
I believe this line:

Expand|Select|Wrap|Line Numbers
  1. var result = p.GetPrinterName;
Should be:

Expand|Select|Wrap|Line Numbers
  1. var result = p.GetPrinterName();
Jun 26 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jonathan | last post by:
I'm puzzled by Python's behavior when binding local variables which are introduced within exec() or execfile() statements. First, consider this simple Python program: # main.py def f() : x = 1...
6
by: Prawit Chaivong | last post by:
Hi All I don't know whether I should post this thing to compiler group or this group. Anyway, I decided to post to this group. (I'm sorry if you think I post in wrong group) My question is......
3
by: Christine | last post by:
I am working on code that I have posted several questions on, they have been helpful, but as I am new to programming, I have come across something else I am not sure how to fix. This is a build...
1
by: Grzegorz Smith | last post by:
Hi all. I have got situation that I need make parameter injection into function and I want that parametet be a local variable of that function. eg. something like def decorator(): <code>...
2
by: silverburgh.meryl | last post by:
Can you please tell me what is the meaning this error in general? UnboundLocalError: local variable 'colorIndex' referenced before assignment In my python script, I have a variable define and...
3
by: Antonio | last post by:
Can somebody tell me what's wrong with this code? When I try to debug, I get "Use of unassigned local variable 'ip2se'. string ip2se; if(e.Item.Cells.Text == e.Item.Cells.Text) ip2se =...
2
by: Mirovk | last post by:
Hi, I have a session variable wich value arrives from a previous .asp but in my actual page I need to modify it based upon a selected value from a radio button. I will try to figure out for...
25
by: Sourav | last post by:
Suppose I have a code like this, #include <stdio.h> int *p; void foo(int); int main(void){ foo(3); printf("%p %d\n",p,*p);
3
by: Rene | last post by:
Could someone tell me why is not possible to have Implicitly typed* field level* variables? For example, why won't the following code compile? class Program { var myString = "abc"; static...
25
by: dpapathanasiou | last post by:
I have some old Common Lisp functions I'd like to rewrite in Python (I'm still new to Python), and one thing I miss is not having to declare local variables. For example, I have this Lisp...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.