Looking for C# equivalent of scanf

后端 未结 9 1148
误落风尘
误落风尘 2020-11-29 09:51

I used to code in C language in the past and I found the scanf function very useful. Unfortunately, there is no equivalent in C#.

I am using using it to

9条回答
  •  孤街浪徒
    2020-11-29 10:28

    I think you want the C# library functions either Parse or Convert.

    // here's an example of getting the hex value from a command line 
    // program.exe 0x00080000
    
    static void Main(string[] args)
    {
        int value = Convert.ToInt32(args[1].Substring(2), 16);
        Console.Out.WriteLine("Value is: " + value.ToString());
    }
    

提交回复
热议问题