using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
publicstaticclass Extensions {
publicstatic string SpaceToUnderscore(this string source) {
char[] cArray = source.ToCharArray();
string result = null;
foreach (char c in cArray) {
if (Char.IsWhiteSpace(c))
result += "_";
else
result += c;
}
return result;
}
}
class Program {
staticvoid Main(string[] args) {
string s = "This is a test";
Console.WriteLine(s.SpaceToUnderscore());
}
}