- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
public static unsafe int Strlen(byte* data)
{
int i = 0;
while (data[i] != 0)
{
++i;
}
return i;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−4
public static unsafe int Strlen(byte* data)
{
int i = 0;
while (data[i] != 0)
{
++i;
}
return i;
}
Работа с C строками
+1
public static XmlNode FindNodeRecursive(XmlNode document, string nodeName)
{
if (document.Name == nodeName)
return document;
foreach (XmlNode node in document.ChildNodes)
{
if (node.Name == nodeName)
return node;
XmlNode resNode = FindNodeRecursive(node, nodeName);
if (resNode != null && resNode.Name == nodeName)
return resNode;
}
return (XmlNode)null;
}
<...>
XmlDocument document = new XmlDocument();
document.LoadXml(request);
var PurchaseIdNode = XmlProcessing.FindNodeRecursive(document, "PurchaseId");
Разработчик с 15-летним стажем
XPath'у не доверяет
+2
https://tjournal.ru/analysis/128216-moshenniki-3-0-kak-ne-popastsya-na-udochku-novogo-pokoleniya-prestupnikov-v-sfere-it
https://leonardo.osnova.io/0234cd39-a2ef-c6d8-d8df-87df562f9997/-/scale_crop/600x398/center/
0
public static long NextTimestamp()
{
if (initTimestamp == null)
{
lock (syncRoot)
{
if (initTimestamp == null)
{
initTimestamp = false;
var sessionProvider = Locator.GetServiceNotNull<ISessionProvider>();
TimestampService.GetTimestamp();
sessionProvider.CloseSession("");
initTimestamp = true;
}
}
}
return initTimestamp.Value ? TimestampService.GetTimestamp() : 0;
}
Нельзя просто взять и вызвать TimestampService.GetTimestamp() - StackOverflowException получишь. Вот как надо!
+1
using System;
using System.Drawing;
using System.Windows.Forms;
class HTMLCheapRedactor
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Form a = new Form() { Text = "HTML Doc" },
b = new Form() { Text = "HTML Code" };
var web = new WebBrowser() { Dock = DockStyle.Fill };
var txt = new TextBox()
{
Multiline = true,
Dock = DockStyle.Fill,
ScrollBars = ScrollBars.Both,
Font = new Font("Consolas", 12f),
WordWrap = false,
AcceptsTab = true
};
web.DataBindings.Add(new Binding("DocumentText", txt, "Text"));
a.Controls.Add(web);
b.Controls.Add(txt);
b.Show();
b.AddOwnedForm(a);
txt.Text = @"<html>
<head>
<title>Hello World!</title>
</head>
<body>
Hello World!
</body>
</html>";
Application.Run(a);
}
}
+1
if (tableOfVariables[i].Name == "replace".ToUpper())
)))00
+1
private static string GetServerHostFromUrl(string url)
{
char[] delimiterChars = { '/', ':' };
var urlParser = url.Split(delimiterChars);
if (urlParser[0] == "http" || urlParser[0] == "https")
return urlParser[3];
else
return string.Empty;
}
Когда ты умеешь решать все поставленные задачи
0
private List<string> StrSplit(string str)
{
if (!string.IsNullOrEmpty(str))
return str.Split(new char[] { ',', ';', ':' }, StringSplitOptions.RemoveEmptyEntries).ToList();
return null;
}
0
string log = pair;
log += ":";
log += new string(Convert.ToChar(32), 21 - pair.Length); /*spaces*/
0
let res: boolean = result.lmr_customertype === typeOfSaleValue ? false : true;