c# – How to read an int variable if it's an string

If you just want to read a string, try to convert to an integer, and exit the program if it’s not a valid integer, then you’d use int.TryParse, like this: string input = Console.ReadLine(); if (int.TryParse(input, out x)) { // do something with x } else { // input was invalid. } If you want … Read more

Write a library without class and cpp file [closed]

Make sure your .h has a guard. #pragma once Either declare the function inline in your header: inline int added (uint8_t a, uint8_t b){ int r; r=a+b; return r; } Declaring it static works as well. static int added (uint8_t a, uint8_t b){ int r; r=a+b; return r; } Or, if your function is big, … Read more