CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   ASP.NET (http://www.codingforums.com/forumdisplay.php?f=40)
-   -   Operator Cannot be applied to operand (http://www.codingforums.com/showthread.php?t=281035)

coxmg 11-05-2012 06:40 PM

Operator Cannot be applied to operand
 
private double avgdailyprice = 1;

Print("Show this: " && avgdailyprice);

Fou-Lu 11-05-2012 07:23 PM

What language; C#? && is the and operator, you cannot concat with that. Use + for string concatenation. I don't think the && exists in VB.NET; the & would be concat. Although I think that + is overloaded to work with strings in VB.NET as well, but I cannot recall.

alykins 11-05-2012 08:48 PM

def not C# or VB

'Print' as it relates to the context is not a valid C# or VB method

coxmg 11-05-2012 09:21 PM

its C#, thanks, the + worked.

Fou-Lu 11-05-2012 09:43 PM

Quote:

Originally Posted by alykins (Post 1288906)
def not C# or VB

'Print' as it relates to the context is not a valid C# or VB method

Oh yeah good call. That'd be writeline in C#. Java could use print, but only off of a statically imported java.lang.System.out, and would still need out.print called on it.
Perhaps a custom method in place here.

sajjadaslam3 11-07-2012 07:22 PM

You should write + sign for concatenation in C# like console.WriteLine("hello"+"World");


All times are GMT +1. The time now is 10:28 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.