Notifications
Clear all
[Closed] DotNet Find String
Jun 10, 2011 8:04 pm
Hi to all, its my first call for help here.
Shortly, i want to find string (in .net-string) with ignore case.
Convert .net-string to mxs-string is not an option in my case.
-- example code:
s1 = dotNetObject "System.String" "Hello World!"
s2 = dotNetObject "System.String" "world"
s3 = dotNetObject "System.String" "World"
s1.IndexOf (s2) >= 0 -- false
s1.IndexOf (s3) >= 0 -- true
-- can solve it with ToLower/LCase but that's not always a good idea
-- in C# i can say: (s1.IndexOf(s2, StringComparison.OrdinalIgnoreCase) >= 0)
-- but i try to set CompareOptions in Mxs and fail somehow...
com = dotNetClass "System.Globalization.CompareInfo"
opt = dotNetClass "System.Globalization.CompareOptions"
s1.IndexOf s2 opt.OrdinalIgnoreCase
-- Runtime error: No method found which matched argument list
com.IndexOf s1 s2 opt.OrdinalIgnoreCase
-- Runtime error: dotNet runtime exception: Non-static method requires a target.
Thanks in advance for any help
2 Replies
Jun 10, 2011 8:04 pm
s1 = dotNetObject "System.String" "Hello World!"
s2 = dotNetObject "System.String" "world"
s3 = dotNetObject "System.String" "World"
s1.Indexof "world" (dotnetclass "System.StringComparison").OrdinalIgnoreCase
s1.Indexof s2 (dotnetclass "System.StringComparison").OrdinalIgnoreCase
s1.Indexof "World"
s1.Indexof s3