Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unset variable in C#?

Tags:

c#

How can I unset variable? For example, PHP has an unset($var) function.

like image 750
Sejanus Avatar asked Oct 13 '08 11:10

Sejanus


People also ask

How do you clear a variable in C?

There is no way to "clear" a variable. You can just overwrite it. If the PIN is wrong, input a new PIN, overwriting the old one.

Can we delete variable?

The Remove-Variable cmdlet deletes a variable and its value from the scope in which it is defined, such as the current session. You cannot use this cmdlet to delete variables that are set as constants or those that are owned by the system.

How do you delete a variable?

To delete a variable from all sessions, add a Remove-Variable command to your PowerShell profile. You can also refer to Remove-Variable by its built-in alias, rv . For more information, see about_Aliases.


1 Answers

There is not really an equivalent to "unset".

The closest match I know is the use of the default keyword.

For example:

MyType myvar = default(MyType); string a = default(string); 

The variable will still be "set", but it will have its default value.

like image 61
Nico Avatar answered Sep 21 '22 08:09

Nico