Возможные реализации будут использовать пример String.Split или Regex.Match
.
public void parseFromString(string input, out int id, out string name, out int count)
{
var split = input.Split(',');
if(split.length == 3) // perhaps more validation here
{
id = int.Parse(split[0]);
name = split[1];
count = int.Parse(split[2]);
}
}
или
public void parseFromString(string input, out int id, out string name, out int count)
{
var r = new Regex("(\d+),(\w+),(\d+)", RegexOptions.IgnoreCase);
var match = r.Match(input);
if(match.Success)
{
id = int.Parse(match.Groups[1].Value);
name = match.Groups[2].Value;
count = int.Parse(match.Groups[3].Value);
}
}
Редактирование: Наконец, у SO есть куча потока на реализацию scanf в C # Поиск эквивалента C # для scanf как сделать sscanf в c #