I use this command to check for the Computername wich returns:

SystemInformation::ComputerName->ToString();
//returns: MYCOMP-EG03R8F

When manually rightclicking "My Computer" and check what name I have, it says with lowcase letters:

mycomp-eg03r8f

So it doesn´t return the correct name. It shows Capitals.

But if I do this command instead:

SystemInformation::ComputerName->ToLower()->ToString();

I do get the same computername:

mycomp-eg03r8f


Is it okay to use ->ToLower() when it is a mix with letters and numbers. The function is intelligent and separates letters from numbers ?

Thank you if someone can confirm that...

Judging by the fact that you got the expected output, and not an error, it seems like a safe assumption, doesn't it? If you're concerned about it, run some tests on varying inputs. You'll probably find that it works fine. My guess is that the toLower() function uses the ASCII table to verify that something is a letter and acts appropriately (there are plenty of symbols that aren't letters OR numbers). Also, are you sure you can't look at the function's code yourself, by looking in some standard library?

thank you ArkM, I thought of that perheps can be a scenario that I haven´t thought about. I red about the ToLowerInvariant() and it seems to be the right approach for this purpose.

See also ToLowerInvariant() function:
http://msdn.microsoft.com/en-us/library/system.string.tolowerinvariant.aspx.
MS recommends ToLowerInvariant for OS identifiers (file names, registry keys etc)...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.