I often come across situations when I need to use the same variable but converted to a different type.
for example:
string port;
...
ValidatePort(int port);
Here in ValidatePort I need to use the same variable port but its type should be integer. In order to do that I need first to convert original port to int and use a temporary variable like iPort or something similar to pass it then to ValidatePort
This is not the only case of naming collision and in every other situation I used different approaches (if I needed a string I called it variableName + String or some other endings)
Is there a naming convention in C# for that or a common approach for naming variables that are similar but of different types?
I would say it is wise to make it obvious what a variable is by looking at it.
you have no idea what that represents. It could be any of these:
I would say
but for your code above, there is no problem with just calling it port as this code is perfectly valid: