long? catCode = null; // Если строка val не пустая, if (!(String.IsNullOrWhiteSpace(val))) { // распознаем в первых цифрах до пробела целое 64-битное число. // Если его там нет, записываем в catCode NULL. // Если его удалось распознать, записываем его в catCode. if (!(Int64.TryParse(val.Split(" ")[0], out long cc))) { catCode = null; } else { catCode = cc; } }
Как переписать этот код чуть понятнее?
⏩Как вариант, можно написать что-то в духе:
public static string LeftDigits(this string str) { if (str == null) return null; if (!str.contains(" ") return null; string left = str.Split(" ")[0]; if (! left.All(Char.IsDigit){ return null; } return left; }
long? catCode = null; // Если строка val не пустая, if (!(String.IsNullOrWhiteSpace(val))) { // распознаем в первых цифрах до пробела целое 64-битное число. // Если его там нет, записываем в catCode NULL. // Если его удалось распознать, записываем его в catCode. if (!(Int64.TryParse(val.Split(" ")[0], out long cc))) { catCode = null; } else { catCode = cc; } }
Как переписать этот код чуть понятнее?
⏩Как вариант, можно написать что-то в духе:
public static string LeftDigits(this string str) { if (str == null) return null; if (!str.contains(" ") return null; string left = str.Split(" ")[0]; if (! left.All(Char.IsDigit){ return null; } return left; }
n the U.S. people generally use Bitcoin as an alternative investment, helping diversify a portfolio apart from stocks and bonds. You can also use Bitcoin to make purchases, but the number of vendors that accept the cryptocurrency is still limited. Big companies that accept Bitcoin include Overstock, AT&T and Twitch. You may also find that some small local retailers or certain websites take Bitcoin, but you’ll have to do some digging. That said, PayPal has announced that it will enable cryptocurrency as a funding source for purchases this year, financing purchases by automatically converting crypto holdings to fiat currency for users. “They have 346 million users and they’re connected to 26 million merchants,” says Spencer Montgomery, founder of Uinta Crypto Consulting. “It’s huge.”