A
A.M
I wrote following finction to exttract items from AD.NET connection string.
For example:
SplitCommaAssignments(cn.ConnectionString,";","=")
return a hash table contains all items in connection string.
I have suspission about the way that i create string array and leave it to
garbage collection inside the for loop. Is it efficient? Does this funcrion
has any performance problem?
Thanks,
Ali
public static System.Collections.Hashtable SplitCommaAssignments(string
str,string strSepparator,string strAssignment)
{
string[] a= str.Split (strSepparator.ToCharArray() );
string[] b;
System.Collections.Hashtable h = new System.Collections.Hashtable ();
for(int i = 0;i<a.GetLength (0);++i)
{
b = a.Split(strAssignment.ToCharArray ());
if (b.GetLength (0)== 2)
{
h.Add(b[0],b[1]);
}
}
return h;
}
For example:
SplitCommaAssignments(cn.ConnectionString,";","=")
return a hash table contains all items in connection string.
I have suspission about the way that i create string array and leave it to
garbage collection inside the for loop. Is it efficient? Does this funcrion
has any performance problem?
Thanks,
Ali
public static System.Collections.Hashtable SplitCommaAssignments(string
str,string strSepparator,string strAssignment)
{
string[] a= str.Split (strSepparator.ToCharArray() );
string[] b;
System.Collections.Hashtable h = new System.Collections.Hashtable ();
for(int i = 0;i<a.GetLength (0);++i)
{
b = a.Split(strAssignment.ToCharArray ());
if (b.GetLength (0)== 2)
{
h.Add(b[0],b[1]);
}
}
return h;
}