constant string Alternative working with helper classes

adherneri

New Member
When working with \[code\]switch\[/code\] \[code\]case\[/code\], for exampleI could use \[code\]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; }\[/code\]
  • 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 :\[code\]fullClassName shrtNm = New fullClassName();\[/code\]then you would like to call it as with\[code\]shrtNm.MethodName();\[/code\]You need to go the 'Long way around' specially if not including the Namespace via \[code\]using\[/code\] statement and you would have to call it like:\[code\]string strnm = MyNameOfNameSpace.fullClassName.ConstantntStrName;\[/code\]instead of: \[code\]string strnm = shrtNm.ConstantStrName;\[/code\]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 \[code\]public enum Elavation{ lvl1, lvl2, lvl3}\[/code\]but then you need to declare it as in the long example plus a \[code\].ToString()\[/code\]Is there any alternative at all?
 
Back
Top