c# – Cannot convert from method group to string

c# – Cannot convert from method group to string

I could tell you had some vb.net experience. In vb.net the parenthesis following a method call are provided by the editor and sometimes just assumed like in .ToString. Ok in vb but not in C#.

getIP.GetIPAddress

needs to be

getIP.GetIPAddress()

and

userID.getUserByID

needs to be

userID.getUserByID()

What the error says is that your are passing method reference instead of a string. When you type userID.getUserByID it is just a reference to that method. When you type userID.getUserByID() you are actualy invoking the method, so the result is the string returned by that method.

If I understand your code, you should just add brackets when calling methods in your ValideBarCode3() method like this

ValidateBarCode3(sBarCode, userID.getUserByID(), getIP.GetIPAddress(),modGlobal.gBoothID = Settings.Default.BoothID);

c# – Cannot convert from method group to string

Leave a Reply

Your email address will not be published. Required fields are marked *