Che è un equivalente di Visual basic 'vbNullChar" in C#cos'è un equivalente vbNullChar in C#?
voglio replicare questa dichiarazione VB in C#
Dim sVersion As String
sVersion = New String(vbNullChar, 255)
Che è un equivalente di Visual basic 'vbNullChar" in C#cos'è un equivalente vbNullChar in C#?
voglio replicare questa dichiarazione VB in C#
Dim sVersion As String
sVersion = New String(vbNullChar, 255)
ho il sospetto che si desidera:?
string sVersion = new string('\0', 255);
(Questo sembra Vorrei provare a fare un passo indietro e vedere se non c'è un approccio più appropriato al problema più grande.)
+1 per l'avvertenza. – jbabey
Attualmente sto convertendo un'applicazione Vb.net in C# .net dove ho trovato questa affermazione che devo scrivere così com'è .. –
D'accordo sul fatto che dovresti guardare a ciò che stai cercando di ottenere piuttosto che semplicemente convertire il codice - altrimenti potresti anche generare il C# dal codice IL. –
Jon Skeet è corretta ...
Inoltre è possibile ottenere questa cosa da qui di seguito il metodo ...
prima Way
char vbNullChar = Convert.ToChar(0);//C# Equivalent to vbNullChar
string sVersion = new string(vbNullChar, 255);
secondo Way
char vbNullChar = Convert.ToChar(0x0);//C# Equivalent to vbNullChar
string sVersion = new string(vbNullChar, 255);
Non hai bisogno di 'Convert.ToChar' - solo' char vbNullChar = (char) 0; 'funzionerà bene, o' char vbNullChar = '\ 0'; ' –
http: // www .pressthered.com/working_with_null_characters_in_c_net/ –