|
|
C#
string[] emails = { "Shakiy@gmail.com", "Mary@hotmail.com", "Glenn@gmail.com", "Hillock@yahoo.com"};
var modEmail = from em in emails
select new
{
EmailID = em,
ModifiedEmail = Regex.Replace(em, "[@]", "[attherate]")
};
foreach (var mo in modEmail)
{
Response.Write(mo.ToString() + "<br/>");
}
VB.NET
Private emails() As String = {"Shakiy@gmail.com", "Mary@hotmail.com", "Glenn@gmail.com", "Hillock@yahoo.com"}
var modEmail = from em in emails ReadOnly Property [New]() As select
em, ModifiedEmail = Regex.Replace(em, "[@]", "[attherate]")
EmailID = em, ModifiedEmail
End Property
For Each mo In modEmail
Response.Write(mo.ToString() & "<br/>")
Next mo
'Like' us on our FaceBook page if you find this blog useful. Thanks!
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |





comments
2 Responses to "Quickly Replace Data in a String Array using LINQ"Do you have a find and replace or is that still done in the select query part.
e.g. I have a datarow in DataTable (or string) but I want to replace "<" to "<" & ">" to ">", etc.
thanks,
George.
string[] emails = { "Shakiy@gmail.com", "Mary@hotmail.com", "Glenn@gmail.com", "Hillock@yahoo.com" };
var newmodEmail = emails.Select(x => new { EmailID = x, ModifiedEmail = Regex.Replace(x, "[@]", "[attherate]") });
Array.ForEach(newmodEmail.ToArray(), Console.WriteLine);
Post a Comment