- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
public static byte[] ConvertStringToByteArray(string str)
{
int i, n;
n = str.Length;
byte[] x = new byte[n];
for (i = 0; i < n; i++)
{
x[i] = (byte)str[i];
}
return x;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+135
public static byte[] ConvertStringToByteArray(string str)
{
int i, n;
n = str.Length;
byte[] x = new byte[n];
for (i = 0; i < n; i++)
{
x[i] = (byte)str[i];
}
return x;
}
Парни я не знаю баян это или нет, я лично не видел, но сторожилам виднее
+133
body = Regex.Replace(Regex.Replace(x.SubTitle ?? "...", @"@\[", ""), @"\]\(([^:]+):(\d+)\)", "");
как индусы юзают регулярки
+135
public string ExportToFile(string filename, string filepath, DataSet dsInput)
{
string sFlag = "Error";
System.IO.StreamWriter sw = new StreamWriter("");
try
{
if (filename.Trim() != "" && filepath != "" && dsInput.Tables[0].Rows.Count != 0)
{
sw = new System.IO.StreamWriter(filepath + filename + ".xls");
int iCol = dsInput.Tables[0].Columns.Count;
for (int i = 0; i < iCol; i++)
{
sw.Write(dsInput.Tables[0].Columns[i]);
if (i < iCol - 1)
{ sw.Write("\t"); }
sw.Write(sw.NewLine);
foreach (DataRow dr in dsInput.Tables[0].Rows)
{
for (int i = 0; i < iCol; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(dr[i].ToString());
}
if (i < iCol - 1)
{ sw.Write("\t"); }
}
sw.Write(sw.NewLine);
}
sw.Close();
sFlag = "Success";
}
}
return sFlag;
}
catch (Exception)
{
return sFlag;
}
}
С какого-то китайского сайта:
http://www.datazx.cn/Forums/en-US/2d129cdc-2705-4035-90e2-063c4c399ae5/action?threadDisplayName=wpf-datagrid-remove-whitespace-from-string-on-clipboard-copy&forum=wpf
Нафиг эксепшены, лучше вернем строку "Error"! Ну или "Success", если этот чудо-код еще и не грохнется.
+134
if (paramList[i].GetType().Equals(typeof(String)))
...
+133
//You can assign Values to the ASPNET RadioButton like this way:
protected void Page_Load(object sender, EventArgs e)
{
RadioButton1.Attributes.Add("value", "ASPNET");
}
//Then you can access the value this way:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(RadioButton1.Attributes["value"].ToString());
}
сегодня для меня стало новостью, что у высокоуровневого контрола asp.net web form RadioButton, который по сути рендерится в <input type="radio">, нет атрибута value.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobutton(v= vs.110).aspx да, его нет.
но сначала я подумал, что все же может это я кривой и не туда смотрю, а потом нахожу велосипед, который предлагает MVP http://forums.asp.net/t/1379187.aspx?Why+does+an+ASP+NET+RadioBu tton+control+not+have+a+property+to+prog ramatically+set+the+value+attribute+
+132
private const double A = -695.0;
private const double B = 1136.0;
private const double C = 172018;
через 10 строк:
topPanel.SplitterDistance = (int)
Math.Round(
(-A*ApplicationDispatcher.Current.ApplicationContainer.Size.Width - C)/B,
MidpointRounding.AwayFromZero) - 5;
и дальше внутри , где-то через 200 строк
topPanel.SplitterDistance = (int)
Math.Round(
(-A * ApplicationDispatcher.Current.ApplicationContainer.Size.Width - C) / B,
MidpointRounding.AwayFromZero) - 5;
больше нигде не используется
+133
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if(ofd.ShowDialog() == DialogResult.OK)
{
gs_path = ofd.FileName;
BinaryReader br = new BinaryReader(new FileStream(gs_path, FileMode.Open, FileAccess.Read));
int sys = 0;
do {
ofset++;
br.BaseStream.Seek(ofset, SeekOrigin.Begin);
if (br.ReadInt64() == 6875716118506401907)
{
if (br.ReadInt64() == 521392779117)
{
sys = 1;
}
}
} while (sys == 0);
br.BaseStream.Seek(ofset + 20, SeekOrigin.Begin);
textBox1.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 24, SeekOrigin.Begin);
textBox2.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 28, SeekOrigin.Begin);
textBox3.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 32, SeekOrigin.Begin);
textBox4.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 36, SeekOrigin.Begin);
textBox5.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 40, SeekOrigin.Begin);
textBox6.Text = br.ReadSingle().ToString();
br.BaseStream.Seek(ofset + 44, SeekOrigin.Begin);
textBox7.Text = br.ReadSingle().ToString();
br.Close();
}
}
...
string gs_path;
int ofset = 0;
public Form1()
{
InitializeComponent();
}
...
private void button2_Click(object sender, EventArgs e)
{
BinaryWriter bw = new BinaryWriter(new FileStream(gs_path, FileMode.Open, FileAccess.Write));
bw.BaseStream.Seek(ofset + 20, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox1.Text));
bw.BaseStream.Seek(ofset + 24, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox2.Text));
bw.BaseStream.Seek(ofset + 28, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox3.Text));
bw.BaseStream.Seek(ofset + 32, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox4.Text));
bw.BaseStream.Seek(ofset + 36, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox5.Text));
bw.BaseStream.Seek(ofset + 40, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox6.Text));
bw.BaseStream.Seek(ofset + 44, SeekOrigin.Begin);
bw.Write(Convert.ToSingle(textBox7.Text));
bw.Close();
}
http://kn1fe-zone.ru/index.php?threads/%D0%9F%D1%80%D0%B8%D0%BC%D0%B5%D1%80-%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0% BC%D0%BC%D1%8B-%D1%81-%D0%B0%D0%B2%D1%82%D0%BE%D0%BF%D0%BE%D0% B8%D1%81%D0%BA%D0%BE%D0%BC-%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0% B8%D0%B9.381/
ХОСПАДИ ДЕСЯТЬ ИЗ ДЕСЯТИ!!!!1111 Принесите мачете и спирт!
+134
public static class GlobalFunc
{
// bla-bla-bla ...
public static bool isDouble(string input)
{
Double dec;
return Double.TryParse(input, out dec);
}
public static bool isUShort(string input)
{
ushort dec;
return ushort.TryParse(input, out dec);
}
public static bool isShort(string input)
{
short dec;
return short.TryParse(input, out dec);
}
public static bool IsDate(string input)
{
DateTime date;
return DateTime.TryParse(input, out date);
}
}
face palm
+126
using питух = String;
...
protected питух AccessToken { get; set; }
В память о плавающем
+124
class A
{
a:
Console.WriteLine("Буква А");
goto b;
}
Class B:A
{
b:
Console.WriteLine("Буква Б");
goto a;
}
Моему другу было нечего делать... Побробовал засорить мой комп.