Ok, I hope I can explain this so that everybody understands. I have a database where a column has special characters in the fields. I need to remove these characters before printing them to a file. I have the following code:
public string RemoveSpecialChars(string[] args)
{
string[] chars = new string[]{",",".","/","!","@","#","$","%","^","&","*","'","\"",";","-","_","(",")",":","|","[","]"," "};
string[] str = new string[]{};
for(int i = 0; i< chars.Length; i++ )
{
if(str.Contains(chars[i]))
{
str = str.Replace(chars[i].ToString(),"");
}
}
return str.ToSting();
}
Then I use the above code like this:
dataType.HL7TypeComponent = RemoveSpecialChars(HL7TypeComponent);
So in the first code I am trying to use an array to collect all the field when it is read from the database. Problem is I do not know how long the array will be because it is coming from the database. First of all I am not sure the code above is correct or if I should even be using an array. Second of all I am getting to errors:
“'System.Array' does not contain a definition for 'Replace' and no extension method 'Replace' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)”
And
“'System.Array' does not contain a definition for 'ToSting' and no extension method 'ToSting' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)”
I am using using System.Linq; so I am not sure what I am missing or what I am doing wrong. Can someone please help? Thank you.