In the previous part (Python Bottle Guide (Translation) Part 2 - Hello World) we created a simple Web application with one single route, here is the part of the code with routing from the 'Hello World' example: @route('/hello') def hello…
Below is an example of correctly canceling a transaction with an error: update Params set Value=168 where Param = 'SessionHoursLimit' PRINT @@TRANCOUNT BEGIN TRY BEGIN TRAN PRINT @@TRANCOUNT update Params set Value=167 where Param = 'SessionHours…
Example: using System; using Newtonsoft.Json; using System.Xml.Linq; namespace ConsoleAppTest { class Program { static void Main(string[] args) { string xml = @"<response><user>Roman</user><status>Active</status></response>"; XDocument doc =…
Example of a method that makes a request data to the server and receives a response res at the specified address url : public static string ServerRequest(string data, string url) { string res = ""; try { // To check SSL and just went and took what they give p...
Starting from C# 7 version, the language has a feature that allows declaring a local variable that references an array element or a field in an object: int[] simpleArray = {0, 1, 2, 3, 4, 5, 6, 7, 8}; ref int simpleElementRef = ref simpleArra…
Example of adding logging to a .NET Core Web application based on NLog. Initially, add the NLog.Web.AspNetCore package via Nuget. Then add a nlog.config file to the project root with the following content: <?xml version="1.0" encoding="utf-8"?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd" autoReload="true">
<targets>
<target name="file" xsi:type="FileTarget" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message}" />
</targets>
</nlog>
The log cleanup process should be done regularly, and a professional administrator should be responsible for it. However, it may happen that on your small development project for testing, logs unexpectedly exceed the set size and the following problem arises:
Good news, now you can implement SWITCH in a new way. In C# 8, switch expressions are introduced, which implement a shorter syntax for returning a value. Here is the syntax of the SWITCH expression example:
Sometimes you have to deal with converting a sentence in Russian to a Russian text but in Latin (translit), for example, when sending SMS to reduce costs - because Latin usually fits more and is cheaper. Or when bringing links to a website in a convenient form without Cyrillic, or simply for sending information to solve problems with coding in this exotic way, there are many options where this may be useful.
Simple example of a class with a method for getting a square preview image in .NET Core, using the SixLabors.ImageSharp library. Example: using SixLabors.ImageSharp; using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Pixe…