Is it safe to use _ in class names?
What's the best replacement for . in naming? (Currently I use _.)
It's safe to do so for one underscore at a time, although you shouldn't use two consecutive underscores. From the C# language spec, section 2.4.2:
Identifiers containing two consecutive underscore characters (U+005F) are reserved for use by the implementation. For example, an implementation might provide extended keywords that begin with two underscores.
Personally I try to avoid type names with underscores anyway though... I'm not sure what you mean by "replacement for ." though. If you could give some context, that would help.
. I mean if you have a class to do something with a website, since the address contains . what's your choice for replacing . ?As others have mentioned, it is safe. However, Microsoft's Class Naming Guidelines read:
Do not use the underscore character (_).
As Jon Skeet mentioned, a good alternative would be to replace . with Dot. For example, a class related to drive.google.com could be named DriveDotGoogle. (I think the DotCom portion could be omitted so as not to unnecessarily lengthen the name.)
Yes, it is safe.
You should never even consider having a "." in a class name. I can't imagine when they would come up. Perhaps if you wanted to name something ".NET" you would do with "DotNet". Class names should be concise, and personally, I've never used an underscore in one. I prefer camel casing.
You may consider reading MSDN - Naming Guidelines.
Dot idea. So I can use: GoogleDotCom when need a ..com website via another property, etc, it doesn't need to be in the class name).Namespace.Typename. The namespace construct is effectively a high-level language feature that parses dots as namespace separators.Sounds like your generating CSharp code. If this is the case you may want to look at the following helper routine from the System.Design assembly:
http://msdn.microsoft.com/en-us/library/ms145952.aspx
static string FixName(string givenName) { return System.Resources.Tools.StronglyTypedResourceBuilder.VerifyResourceName( givenName, new Microsoft.CSharp.CSharpCodeProvider()); }
best practicerather than working or not working.