dataGridView1[0,1].Value = "Какое то новое значение".
dataGridView1.DataSource = Grep();
dataGridView1.Refresh();
dataGridView1.Update();
public class User : INotifyPropertyChanged
{
private string _name;
private int _age;
public string Name
{
get => _name;
set { _name = value; OnPropertyChanged(); }
}
public int Age
{
get => _age;
set { _age = value; OnPropertyChanged(); }
}
public User() { }
public User(string name, int age)
{
Name = name;
Age = age;
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
var itemStates = new List<User>()
{
new User("Анимэшник", 0),
new User("Не анимэшник", 18)
};
var bindingList = new BindingList<User>(itemStates);
var source = new BindingSource(bindingList, null);
dataGridView1.DataSource = source;
await Task.Run(async () =>
{
for (int i = 18; i < 30; i++)
{
await Task.Delay(1000);
itemStates.Where(user => user.Name.Equals("Не анимэшник")).FirstOrDefault().Age = i;
}
});
var words = new[] { "Привет", "меня", "зовут", "*", "Мой", "возраст", "таков" };
var variables = new Dictionary<string, string>()
{
{"name", string.Empty},
{"age", string.Empty}
};
var items = words.Select((word, index) => new
{
Item = word,
Index = index,
Group = words.Skip(index)
.Select((wordFind, indexFind) => new
{
Item = wordFind,
Index = indexFind + index
})
.FirstOrDefault(wordFilter => wordFilter.Item.Equals("*"))
}).GroupBy(wordGroup => wordGroup.Group?.Index);
foreach (var item in items)
{
var groupped = string.Join(" ",
item.Select(word => word.Item)
.Where(word => !word.Equals("*")));
var key = variables.Where(keyVariable => keyVariable.Value.Equals(string.Empty))
.Select(keyVariable => keyVariable.Key).FirstOrDefault();
if (key != null && variables.ContainsKey(key))
{
variables[key] = groupped;
}
}
Debug.WriteLine(
string.Join("\n", variables.Select(wordsObject =>
$"key: {wordsObject.Key}, value: {wordsObject.Value}")));
var array = new[] { 55, 2, 9, 99, 12, 13, 23, 32, 5, 11, 1 };
for (var first = 0; first < array.Length; first++)
{
for (var second = first; second < array.Length; second++)
{
if (array[first] % 2 == 1 && array[second] % 2 == 1 && array[first] > array[second])
{
var temp = array[first];
array[first] = array[second];
array[second] = temp;
}
}
}
var sorted = num0.OrderBy(item => item);
var cookies = await Cef.GetGlobalCookieManager().VisitAllCookiesAsync();
client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
public static string PythonRequestTemplate(string headers)
{
var template = $@"import requests
headers = {{ {
headers
} }}
response = requests.get('test.com', headers = headers)";
return template;
}
var headers = new Dictionary<string, string>();
headers.Add("user-agent", "mozilla");
headers.Add("pragma", "no-cache");
headers.Add("referer", "google.com");
Console.WriteLine(PythonRequestTemplate(headers.Select(item => item.Key + ":" + item.Value).Aggregate((item1, item2) => item1 + ",\n" + item2)));
var data = "0, 1.1, 1.2, 1.3, name, true";
var myClass = MyClass.Parse(data);
MyClass.SeeChanges(myClass);
public class MyClass
{
private int Id { get; set; }
private double X { get; set; }
private double Y { get; set; }
private double Z { get; set; }
private string Name { get; set; }
private bool Active { get; set; }
public static MyClass Parse(string data)
{
var myClass = new MyClass();
var properties = data.Split(',');
var props = myClass.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public
| BindingFlags.Instance | BindingFlags.Static);
for (int i = 0; i < props.Length; i++)
{
var prop = props[i];
var type = prop.PropertyType;
prop.SetValue(myClass, Convert.ChangeType(properties[i], type, CultureInfo.InvariantCulture));
}
return myClass;
}
public static void SeeChanges(MyClass myClass)
{
var props = myClass.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public
| BindingFlags.Instance | BindingFlags.Static);
foreach (var prop in props)
{
Debug.WriteLine("{0} = {1}", prop.Name, prop.GetValue(myClass, null));
}
}
}