Posted By: cheong | Jan 14th @ 8:50 PM
page 1 of 1
Comments: 14 | Views: 834
Delimited comment.

In C#, I can write:
string[] dec_val = txt_box1.value.Split(new char[] {'-'})
if ((dec_val.length < 5) /* Check element count */ || (dec_val(1).length) < 2) /* Variable 1 */ || ...

In VB.NET, we only have "line comment", so we need to break it into multiple lines to obtain similar effect...
I agree too, what comment delimiter would you suggest for that?

/' block comment '/ <- maybe?
Sven Groot
Sven Groot
My name has 9 letters. Coincidence? I think not...

My vote goes to Comment/End Comment, it's VB after all. Tongue Out

Disclaimer: I love VB, therefore I'm allowed to make fun of it. Wink

not funny, Ruby uses =begin/=end Smiley

the issue with that style is that it looks strange for one-line comments embedded in a one line of code

Meh, doesn't bother me since I never use inline comments like that, even outside of VB.

The thing that does bother me is that there's no easy way to cast objects.  C# gets the nice

(type)variable
 
but VB has to do

DirectCast(object,Type)

stevo_
stevo_
Human after all
I think the example you shown lacks syntax highlighting Wink.. as plain text it looks horrible, but with colour differences the comments look fine, but also I don't really think it has much effect to put the comment above or next to.. personally I comment above, and only if it needs to be explained.
Sven Groot
Sven Groot
My name has 9 letters. Coincidence? I think not...
It's still slightly better than C++'s static_cast<type>(object) and the myriad of related casts (reinterpret_cast, dynamic_cast, const_cast, constructor-style cast) that all have slightly different semantics. Of course C++ can do the (type)object C-style cast, but they are not always safe to use.
figuerres
figuerres
???
so you folks like
"if ((dec_val.length < 5) /* Check element count */ || (dec_val(1).length) < 2) /* Variable 1 */ || ..."

as a way to comment your code ???

WTF !!????? 

that is just SICK!!
or is everyone just having a joke?

more like this:

[DllImport("iphlpapi.dll", ExactSpelling = true, SetLastError=true)]
public static extern int SendARP(int DestIP, int SrcIP, /*out is the resolved mac*/byte[] pMacAddr, /*mac size*/ref uint PhyAddrLen);
Yggdrasil
Yggdrasil
Pour me a cab, 'cause I can't drink no more.
I think both of these options are much, much clearer:

EDIT: Ugh, code highlighting seems totally borked.

// pMacAddr - buffer that will be filled with the resolved MAC address.
// PhyAddLen - length, in bytes, of MAC address.
[DllImport("iphlpapi.dll", ExactSpelling = true, SetLastError=true)]
public static extern int SendARP(int DestIP,  int SrcIP,  byte[] pMacAddr, ref uint PhyAddrLen);

-- OR --
[DllImport("iphlpapi.dll", ExactSpelling = true, SetLastError=true)]
public static extern int SendARP(
int DestIP,  
int SrcIP,  
byte[] pMacAddr,  // pMacAddr - buffer that will be filled with the resolved MAC address.
ref uint PhyAddrLen);   // PhyAddLen - length, in bytes, of MAC address.
I agree, that was just some random code at hand with the comments added later. I do use that type of comments from time to time, when it makes sense, though. Some like apples others likes oranges....
Sven Groot
Sven Groot
My name has 9 letters. Coincidence? I think not...
I'm just trying to highlight your code, if it's not working it could be my fault after all:
// pMacAddr - buffer that will be filled with the resolved MAC address.<BR>// PhyAddLen - length, in bytes, of MAC address.<BR>[DllImport("iphlpapi.dll", ExactSpelling = true, SetLastError=true)]<BR>public static extern int SendARP(int DestIP,  int SrcIP,  byte[] pMacAddr, ref uint PhyAddrLen);<BR><BR>[DllImport("iphlpapi.dll", ExactSpelling = true, SetLastError=true)]<BR>public static extern int SendARP(<BR>int DestIP,  <BR>int SrcIP,  <BR>byte[] pMacAddr,  // pMacAddr - buffer that will be filled with the resolved MAC address.<BR>ref uint PhyAddrLen);   // PhyAddLen - length, in bytes, of MAC address.


Seems ok, except for the overflow, but that's always been broken.

Out of curiosity, why do people do this:

string s = ...;
string[] t = s.Split(new char[] { '-' });

When they can do this:

string s = ...;
string[] t = s.Split('-');
page 1 of 1
Comments: 14 | Views: 834
Microsoft Communities