Could someone please tell me which objects types can be tested using Regular Expressions in C#?
+5
A:
If I understand you correctly and you are asking which object types can be tested against regular expressions then the answer is: strings and only strings.
Thus your test would be:
if(obj is string){...}
Manu
2008-11-05 23:05:54
Yes, which object types can tested against regular expressions si what I was looking for.
Michael Kniskern
2008-11-05 23:09:27
I have edited your question inline with your comment to this answer.
Xenph Yan
2008-11-05 23:14:44
+3
A:
Regular expressions only apply to strings. What does it even mean to apply a regular expression to (say) a SqlConnection?
If you need some other sort of pattern matching (e.g. being able to match the values of particular properties) you should think about and then explain those requirements in detail.
Jon Skeet
2008-11-05 23:10:12
+1
A:
I suppose you could always use the Regular Expression against Object.ToString(), which could be helpful if you override ToString() to give information about your object that you want to match against.
Ray
2008-11-05 23:12:19