如何从不区分大小写的字符串中获取游标(例如从 "hand" 而不是 "Hand")?
How to get a Cursor from a case-insensitive string (ex. from "hand" instead of "Hand")?
我有特定类型的鼠标光标的字符串表示,在几种不同的情况下,例如:"Hand"、"hand"、"haNd" 等
如何在忽略字符串大小写的情况下获得正确的 Cursor
?
TypeConverter.ConvertFromString
方法不支持 StringComparison
参数。
var cursor = CursorConverter().ConvertFromString("hand"); // not "Hand"
你可以使用反射得到你想要的Cursor
属性,同时忽略字母大小写:
var cursor = (Cursor)typeof(Cursors).GetProperty("haNd",
BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Static).GetValue(null);
查看 documentation,我在 CursorConverter
class 中没有看到任何允许您忽略大小写的内容。
我有特定类型的鼠标光标的字符串表示,在几种不同的情况下,例如:"Hand"、"hand"、"haNd" 等
如何在忽略字符串大小写的情况下获得正确的 Cursor
?
TypeConverter.ConvertFromString
方法不支持 StringComparison
参数。
var cursor = CursorConverter().ConvertFromString("hand"); // not "Hand"
你可以使用反射得到你想要的Cursor
属性,同时忽略字母大小写:
var cursor = (Cursor)typeof(Cursors).GetProperty("haNd",
BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Static).GetValue(null);
查看 documentation,我在 CursorConverter
class 中没有看到任何允许您忽略大小写的内容。