Ik heb al even gezocht en onderandere deze converter gebruikt: http://www.codeproject.com/csharp/gbvb.asp, maar zonder resultaat.
Ik zou zelf deze code van VB.NET:
Zo vertalen:
Ik krijg nu echter een fout "Cannot implicitly convert type 'System.Array' to 'string'" op de regel van roleList.ToArray
En in de laatste regel: "Argument '2': cannot convert from 'string' to 'string[]'"
Iemand een idee?
Ik zou zelf deze code van VB.NET:
code:
1
2
3
4
5
6
7
8
9
10
11
| ' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read()
roleList.Add(reader("sGroupName"))
Loop
'Convert the roleList ArrayList to a String array
Dim roleListArray As String() = roleList.ToArray(GetType(String))
'Add the roles to the User Principal
HttpContext.Current.User = New GenericPrincipal(User.Identity, roleListArray) |
Zo vertalen:
code:
1
2
3
4
5
6
7
8
9
10
11
12
| //Create an array of role names
ArrayList roleList = new ArrayList();
while(oReader.Read()) {
roleList.Add(oReader.GetSqlString(0));
}
//Convert the roleList ArrayList to a String array
//string[] sRoleListArray = roleList.ToArray(GetType("string"));
string sRoleListArray = roleList.ToArray(System.Type.GetType("System.String"));
//Add the roles to the User Principal
HttpContext.Current.User = new GenericPrincipal(HttpContext.Current.User.Identity, sRoleListArray); |
Ik krijg nu echter een fout "Cannot implicitly convert type 'System.Array' to 'string'" op de regel van roleList.ToArray
En in de laatste regel: "Argument '2': cannot convert from 'string' to 'string[]'"
Iemand een idee?