![](/img/trans.png)
[英]How could I pass enum object with nested enum in it to a method as parameter?
[英]How do I pass parameter of type enum to a method in Apex?
public class EnumTest { Public enum Season {Spring,Summer,fall,winter} Public static Void SeasonFinder(Season CurrentSeason) { If(CurrentSeason == Season.Spring || CurrentSeason == Season.fall ) { System.debug('Neither cold nor hot'); } else if(CurrentSeason == Season.Summer) { System.debug('It is hot'); } Else if(CurrentSeason == Season.Winter) { System.debug('It is Cold'); } Else { System.debug('Invalid Season'); } } }
我需要拨打 function SeasonFinder。 但是如何传递类型季节的参数? 我收到像可变季节不存在这样的错误。
您必须将其称为 static,因此调用将如下所示:
seasonTest.SeasonFinder(EnumTest.Season.Summer)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.