lock { }
сделать. Тебя компилятор поругает struct SomeStruct: IInterface
{ }
void DoSomethingStruct(SomeStruct s)
{ }
void DoSomethingInterface(IInterface i)
{ }
void Main()
{
var s = new SomeStruct();
// Без боксинга
DoSomethingStruct(s);
// Боксинг
DoSomethingInterface(s);
}
data
тип IReadOnlyDictionary - в него нельзя записывать значения.async Task<object?> MethodFirst(IReadOnlyDictionary<string, object>? data)
{
var result = new Dictionary<string, object>();
foreach (var product in Enum.GetValues(typeof(ProductType)))
{
var price = await GetCentreProductSolutionLowestPrice(countryIsoCode3, (ProductType)product, null, context.Culture, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(price))
{
return await GetContentById(context, PleaseCallUs, "Please call us", cancellationToken, data);
}
result.Add("some data", new object());
}
return result;
}
var document = new XmlDocument();
document.LoadXml("""
<ArrayOfClient>
<Client>
<Id>1</Id>
<Login>hihihaha</Login>
<Password>P@ssW0rd</Password>
</Client>
<Client>
<Id>2</Id>
<Login>blabla</Login>
<Password>P@ssW0rd</Password>
</Client>
<Client>
<Id>3</Id>
<Login>login</Login>
<Password>P@ssW0rd</Password>
</Client>
</ArrayOfClient>
""");
var login = "blabla";
var foundNode = document.SelectSingleNode($"//Client/Login[text()='{login}']");
if (foundNode is not null)
{
foundNode = foundNode.ParentNode!;
var passwordNode = foundNode.SelectSingleNode("./Password")!;
passwordNode.InnerText = "new password";
document.Save("result.xml");
}