Remove Single Quote
public static string RemoveSingleQuote(string data)
{
return string.IsNullOrEmpty(data) ? string.Empty : data.Replace("'", "''");
}
public static T RemoveSingleQuote<T>(object ob)
{
PropertyDescriptorCollection props =
TypeDescriptor.GetProperties(typeof(T));
T Tob = (T)ob;
if (Tob != null)
{
for (int i = 0; i < props.Count; i++)
{
PropertyDescriptor prop = props[i];
if (prop.PropertyType.Name == "String")
{
object oPropertyValue = prop.GetValue(Tob);
oPropertyValue = RemoveSingleQuote((string)oPropertyValue) as object;
oPropertyValue = RemoveSpace((string)oPropertyValue) as object;
prop.SetValue(Tob, oPropertyValue);
}
//oPropertyValue
//table.Columns.Add(prop.Name, prop.PropertyType);
}
}
return Tob;
}
{
return string.IsNullOrEmpty(data) ? string.Empty : data.Replace("'", "''");
}
public static T RemoveSingleQuote<T>(object ob)
{
PropertyDescriptorCollection props =
TypeDescriptor.GetProperties(typeof(T));
T Tob = (T)ob;
if (Tob != null)
{
for (int i = 0; i < props.Count; i++)
{
PropertyDescriptor prop = props[i];
if (prop.PropertyType.Name == "String")
{
object oPropertyValue = prop.GetValue(Tob);
oPropertyValue = RemoveSingleQuote((string)oPropertyValue) as object;
oPropertyValue = RemoveSpace((string)oPropertyValue) as object;
prop.SetValue(Tob, oPropertyValue);
}
//oPropertyValue
//table.Columns.Add(prop.Name, prop.PropertyType);
}
}
return Tob;
}
Comments
Post a Comment