十进制转二进制错误

Decimal to Binary Conversion Error

如何解决以下从十进制转换为二进制的问题?

void tobinary(int bin) {
    string binary = Convert.ToInt32(bin, 2);
}

这些是错误:

Error 2: Argument 2: cannot convert from 'int' to 'System.IFormatProvider' 42

Error 1: The best overloaded method match for 'System.Convert.ToInt32(object, System.IFormatProvider)' has some invalid arguments 42

见: Decimal to binary conversion in c #

应该是:

void tobinary(int bin) {
string binary = Convert.ToString(bin, 2);}