Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Sep 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Operator Cannot be applied to operand

    private double avgdailyprice = 1;

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

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    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.

  3. #3
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    2,044
    Thanks
    50
    Thanked 210 Times in 209 Posts
    def not C# or VB

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

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  4. #4
    New Coder
    Join Date
    Sep 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    its C#, thanks, the + worked.

  5. #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    17,027
    Thanks
    4
    Thanked 2,668 Times in 2,637 Posts
    Quote Originally Posted by alykins View Post
    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.

  6. #6
    New to the CF scene
    Join Date
    Nov 2012
    Location
    Islamabad
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You should write + sign for concatenation in C# like console.WriteLine("hello"+"World");


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •