Си диез / Говнокод #17568 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
private double readDouble(string name, string wholeFile)
{
	try
	{
		int ind = -1;
		if ((ind = wholeFile.IndexOf(name)) != -1)
		{
			var restofstr = wholeFile.Substring(ind + name.Length);
			int lineendind = -1;
			lineendind = restofstr.IndexOfAny(new char[] { '\n', '\r', (char)13, (char)10 });
			if (lineendind == -1 && restofstr.Length > 1)
			{
				lineendind = restofstr.Length;
			}
			if (lineendind != -1)
			{
				int eqind = -1;
				string valueString = restofstr.Substring(0, lineendind);
				if ((eqind = valueString.IndexOf("=")) != -1)
				{
					double res = 0.0;
					if (Double.TryParse(valueString.Substring(eqind + 1).Trim(), out res))
					{
						return res;
					}
				}
			}
		}
	}
	catch (Exception) { }

	return 0.0;
}

А как бы вы написали это?

Запостил: tbolk tbolk, (Updated )

Комментарии (2) RSS

Добавить комментарий

Помни, guest, за тобой могут следить!

    А не использовать ли нам bbcode?


    8