Case 1:
myString =Regex.Replace(myString,"/kg","",RegexOptions.IgnoreCase);
Case 2: If you're going to do this a lot of times, you could do:
// You can reuse this object
Regex regex =newRegex("/kg",RegexOptions.IgnoreCase);
myString = regex.Replace(myString,"");
jimili 發表在 痞客邦 留言(0) 人氣()
Column names
If a column name contains any of these special characters ~
(
)
#
\
/
=
>
<
+
-
*
%
&
|
^
'
"
[
]
, you must enclose the column name within square brackets [
]
. If a column name contains right bracket ]
or backslash \
, escape it with backslash (\]
or \\
).
http://www.csharp-examples.net/dataview-rowfilter/
jimili 發表在 痞客邦 留言(0) 人氣()
List<string> lstSCol = new List<string>();
foreach (string sSC in sOutputColumn.Split(','))
if (dtResult.Columns.Contains(sSC))
lstSCol.Add(sSC);
for (int iS = 0; iS < lstSCol.Count; iS++)
dtResult.Columns[lstSCol[iS]].SetOrdinal(iS);
jimili 發表在 痞客邦 留言(0) 人氣()
private DataTable ConvertToTable(string sVal)
{
DataTable dt = new DataTable();
if (sVal.Length > 0)
{
string[] asVal = sVal.Replace(Environment.NewLine, "\n").Split('\n');
foreach (string sVC in asVal[0].Split(','))
dt.Columns.Add(sVC);
for (int i = 1; i < asVal.Length; i++)
{
string[] asVV = asVal[i].Split(',');
object[] aobj = new object[asVV.Length];
for (int j = 0; j < asVV.Length; j++)
aobj[j] = asVV[j];
dt.LoadDataRow(aobj, true);
}
}
return dt;
}
jimili 發表在 痞客邦 留言(0) 人氣()
private string ReadTextFileFromResource(string sFile)
{
string sRet = "";
try
{
Assembly assembly = Assembly.GetCallingAssembly();
StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream(<File name with full namespce>));
sRet = textStreamReader.ReadToEnd();
textStreamReader.Close();
}
catch (Exception err)
{
MessageBox.Show(this, err.Message, "Error");
}
return sRet;
}
jimili 發表在 痞客邦 留言(0) 人氣()