Seb*_*563 2 .net c# variables parameters methods
我想用某种设置创建方法,当然我可以使用int Para然后使用if == 1,if if == 2等一些ifs但我不想要这个.我的谷歌技能不允许我搜索解决方案,因为我错过了一些单词或别的东西,一些短语.我想让它看起来像:
void Method(int var1, int var2, Settings.type.type1){
if(type1){
}
if(type2){
}
if(type3){
}
}
Run Code Online (Sandbox Code Playgroud)
在框架中的一些方法中,我看到了类似这样的东西:templateType.DefoultTemplate.我不想要字符串!我想要清楚的参数.对不起我的英语不好
public enum CustomType {
Type1 = 1,
Type2 = 2,
Type3 = 3
};
public void Method(CustomType t)
{
switch (t)
{
case CustomType.Type1:
// code here
break;
case CustomType.Type2:
// code here
break;
case CustomType.Type3:
}
}
Run Code Online (Sandbox Code Playgroud)