In my Post Using Json In Asp.net , when writing the code for the example i choose VB.Net for developing the web application. During the application development i came across little problem to place double quotes around the string. As i am working in C# for last 2 and half year and still working in C sharp, the first thought which came to my mind was to place \" but i was wrong in thinking so. So i start searching how to place the double quotes around string in VB.net. During my Search i found ControlChars class which define the constants for the such characters. I have used the quote Constant in my code to place double quotes around my string.Here are some of the important constants in the class along with there description, i not mention all the constant.
VB.Net Value | Description |
---|---|
ControlChars.Cr | Carriage Return |
ControlChars.Lf | Line Feed |
ControlChars.CrLf | Carriage Return|Line Feed |
ControlChars.NewLine | Insert New Line |
ControlChars.Tab | Tab |
ControlChars.Quote | Quotation mark character (" or ') used to enclose values. |
ControlChars.Back | BackSpace |
For C sharp developer you can use this class by importing Microsoft Visual Basic namespace which is "Microsoft.VisualBasic" , When you place the Microsoft.VisualBasic at the top of your file you can access the constants define in the ControlChars class. Or if you don't want to import the Microsoft.VisualBasic namespace then you can define your own class and define the constant like VB.Net.
All and any comments / bugs / suggestions are welcomed!
All and any comments / bugs / suggestions are welcomed!
2 comments:
The ControlChars class is there for VB6 compatibility, although there's harm in using it.
What do you think about using the Chr(34)?
*no harm in using it :)
Post a Comment