When working with switch case, for example
I could use
const string FirstFloor = "lvl1", SecondFloor = "lvl2", ThirdFloor = "lvl3";
string ElavaetTo= "lvl1";
switch(ElavaetTo)
{
case FirstFloor:
Response.Redirect(FirstFloor + "Page.aspx")
break;
case SecondFloor:
Response.Redirect(SecondFloor + "Page.aspx")
break;
case ThirdFloor:
Response.Redirect(ThirdFloor + "Page.aspx")
break;
}
- Edited :
this is only an example of where constant string wil not work if placed in another class
this is not a function / method i am trying to correct so it will work.
thanks for your time, i am trying to base my methods , my approach…
This would work fine placed in the current or same class of the project but when all variables are stored outside this class instead of simply instantiating the class and methods only once :
fullClassName shrtNm = New fullClassName();
then you would like to call it as with
shrtNm.MethodName();
You need to go the ‘Long way around’ specially if not including the Namespace via using statement
and you would have to call it like:
string strnm = MyNameOfNameSpace.fullClassName.ConstantntStrName;
instead of:
string strnm = shrtNm.ConstantStrName;
Is there an alternative to using any type that will represent string values inside the IntelliSense in an easy way ?
I have tried to use
public enum Elavation
{
lvl1,
lvl2,
lvl3
}
but then you need to declare it as in the long example plus a .ToString()
Is there any alternative at all?
as far as i could get (only because it was important for me to addapt an aproach )
i found an example in a codeProjec page about using strings and String-Enumerations
that lead me to use that aproach and then turn my calss into a static class
}
using
sealed classaccessing it via its parent className.Itsnamee.g.
as edit would show in IntelliSense