"Invisible" & sign.

This is a discussion on "Invisible" & sign. within the C# Programming forums, part of the General Programming Boards category; I can't cut/paste because the machine with the IDE is not connected to the net! I place a label on ...

  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    42

    "Invisible" & sign.

    I can't cut/paste because the machine with the IDE is not connected to the net!

    I place a label on the screen, and a button. When the button is pressed, it does:

    label1.Text = ">>>&<<<";

    What shows up on the screen is >>><<<. If I take the length of the .Text field it shows 7. If I write >>>&&<<< it appears right, (ie. a single ampersand), on the screen, but the length is now 8.

    Whats wrong here?
    Last edited by Fossaw; 03-12-2010 at 05:29 AM.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    Use a verbatim string literal.

    Code:
    label1.Text = @">>>&<<<";
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    The &-char is used to indicate that the following char is used for keyboard shortcuts.

    "&Next" would spell "Next", once you press Alt, it would be "Next" and pressing "N" on the keyboard would select this action.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    42
    Still not present on the screen using the @ operator. It is in a string for example.
    Last edited by Fossaw; 03-12-2010 at 05:56 AM.

  5. #5
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    I wasn't thinking and nvoigt set me straight.

    It wouldn't work. The problem is as nvoigt puts it. For the & sign to stop being treated as a special character, set the UseMnemonic property to false.

    Code:
    label1.UseMenmonic = false;
    label1.Text = ">>>&<<<";
    There's no need for a verbatim string either.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  6. #6
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    42
    Yeah, that works. That's pretty gross isn't it.

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    Not really. The API is free to establish the rules of how it operates. Since Mnemonics is such a fundamental aspect of a Windows GUI, it's perfectly acceptable. What would be gross was for the API to not give you the option to disable mnemonics on a control basis.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    42
    I don't want to get drawn into a debate here. I will say that I have googled, and searched the online documentation here for a couple of days and the solution was not apparent. The product is being pushed as a beginner tool, and beginners are not good at searching for stuff like this. The product is also making great pains to show it's xml features, where the & symbol is frequently used, (indeed, how I came upon the problem), yet I cannot find it there either.

    We disagree, fair enough.

  9. #9
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    Yes, we disagree. Although I'm not sure what product you are talking about.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  10. #10
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    42
    MS Visual Studio 2008, Professional. C# more generally.
    Last edited by Fossaw; 03-12-2010 at 06:56 AM.

  11. #11
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    Hmm... I don't know who told you this was for beginners. It's a programming language. Part of the apprenticeship process is exactly hunting down for answers to things we don't know. As we gather knowledge things start to fit in place and all will appear more easy and make more sense. It's not the other way around. In the beginning everything will appear confusing and difficult.

    That's what being a beginner is all about. Confused, bewildered and sometimes slightly annoyed.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #12
    Registered User
    Join Date
    Mar 2010
    Location
    Denmark
    Posts
    42
    Microsoft have been presenting C# as the way forward to get many new people into development. If you browse the marketting bumph, (), it is full of stuff like that.

    The fact that I could not find it, (I have been a professional software engineer, i.e. in an office being paid for it, for 30+ years), indicates to me that it is not immediately apparent.

  13. #13
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    The & greatly predates C# for its use in mnemonics; it was part of the original WinAPI, and everything that's built upon the WinAPI, including Windows Forms, still recognizes it.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  14. #14
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Use ">>>&&<<<"
    (double &)
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  15. #15
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,403
    It may be a problematic solution if, as implied, you later need to read the string length, magos.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sign ' is the same as \' ?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 11-23-2007, 06:32 AM
  2. My own itoa()
    By maxorator in forum C++ Programming
    Replies: 18
    Last Post: 10-15-2006, 11:49 AM
  3. Handle on MSN Messenger's Sign In "button"?
    By jmd15 in forum Windows Programming
    Replies: 3
    Last Post: 07-16-2005, 09:28 PM
  4. How to detect change in sign?
    By bugsmashers in forum C++ Programming
    Replies: 16
    Last Post: 02-20-2005, 06:27 PM
  5. Sign Up!: The Third Round, both contests
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 54
    Last Post: 07-20-2002, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21