[RESOLVED] Some small doubts while reading other posts
Hi..:wave:
While I was reading some posts, I got stuck at certain lines.
Code:
Public Class IP_ADAPTER_INFO
Public [Next] As IntPtr
'......
Why the square brackets ? :confused:
Code:
Dim Count As Integer = RichTextBox.Text.Split(","c).Length
What's the use of character c in above code?
Thanks...:wave:
Edit:
Ooops. I posted in the wrong section :(
Re: Some small doubts while reading other posts
Moved. (Please specify your .Net version)
Re: Some small doubts while reading other posts
1. they are used to tell the compiler that these are not the predefined words but user defined variables
2. to conver the string into character
Re: Some small doubts while reading other posts
Re: Some small doubts while reading other posts
Quote:
Originally Posted by
MartinLiss
Moved. (Please specify your .Net version)
Thanks for moving this thread...:wave:
Yeah. I have edited the post added the version too.:thumb:
Quote:
Originally Posted by
aashish_9601
1. they are used to tell the compiler that these are not the predefined words but user defined variables
2. to conver the string into character
Thanks...:wave:
But is Next a predefined word ? :confused:
Quote:
Originally Posted by
amrita
Thanks...:wave:
Re: Some small doubts while reading other posts
Quote:
Originally Posted by
akhileshbc
But is Next a predefined word ? :confused:
you asking this question with a 200+ repute, strange
http://msdn.microsoft.com/en-us/libr...9t(VS.71).aspx
http://msdn.microsoft.com/en-us/libr...(v=VS.71).aspx
Re: Some small doubts while reading other posts
Quote:
Originally Posted by
akhileshbc
Thanks...:wave:
But is Next a predefined word ? :confused:
Yes, Next is predefined, a for-Next loop would be very sorry without it
Code:
For <some statement>
'//method body
Next
Re: Some small doubts while reading other posts
Quote:
Originally Posted by
aashish_9601
Quote:
Originally Posted by
J-Deezy
Yes, Next is predefined, a for-Next loop would be very sorry without it
Code:
For <some statement>
'//method body
Next
Ah! Didn't thought about that one :blush:
I was trying to migrate from VB6 to .Net. So, before that I flushed my memory. :lol:
Sorry for my stupid question.
Re: [RESOLVED] Some small doubts while reading other posts
As said, square brackets allow you to use a name (for methods, variables, properties, etc) that is usually reserved for keywords. Other examples are Public, Private, Class, Sub, etc.
As for your second point, the c indicates that it is a character literal and not a string literal of length 1. Even though a character and a 1-letter string are in all usual senses the same, in .NET they are simply two different classes. I would like to correct aashish_9601's answer though: there is no conversion taking place.
Code:
Dim a = "x"
Dim b = "x"c
In this code, a is a String and b is a Char.
The C# equivalent would be
Code:
var a = "x";
var b = 'x';
Since ' is reserved for comments in VB they had to find a different way to distinguish string and char literals, and they chose for a 'c' suffix.
Re: [RESOLVED] Some small doubts while reading other posts