How to use a switch statement with Guid?

后端 未结 2 1829
囚心锁ツ
囚心锁ツ 2021-01-17 13:51

In the following C# code, cboRole returns a Guid.

I\'m then trying to use it in a switch statement to do some actions.

cboRole can return only 4 different G

2条回答
  •  青春惊慌失措
    2021-01-17 14:22

    Your switch statements are in upper-case while your ToStringEx() returns the Guid in lower-case.

    You can use

    switch (cboRole.EditValue.ToStringEx().ToUpper())
    

    or modify your case statements.

提交回复
热议问题