• In chevron_right

      Create an exception handler in ASP.NET Core 8

      pubsub.slavino.sk / infoworldcom · Thursday, 1 February - 10:00 edit

    Microsoft’s November release of .NET 8 brought all kinds of great new features . One of the nice improvements introduced in ASP.NET Core 8 is IExceptionHandler, an interface that makes it easier to handle exceptions gracefully in ASP.NET Core web applications.

    Error handling has a long history in programming languages and frameworks. IExceptionHandler simplifies error handling by providing a callback and a central location for handling known exceptions. In this article we’ll discuss how you can use IExceptionHandler in your ASP.NET Core 8 applications and present meaningful error responses to the user.

    To read this article in full, please click here


    Značky: #Rozne, #C#

    • In chevron_right

      How to implement a custom object mapper in C#

      pubsub.slavino.sk / infoworldcom · Thursday, 18 January - 10:00 edit

    When working on applications, you will often need to convert one type to another. Object mapping is the process of mapping a source object to a destination object, where the types of the source and destination objects might differ.

    For example, you might need to create an instance of one class from an instance of another class, then copy the data from the source object to the destination object. Although there are many object mappers available to use, you may need to implement your own custom mappers in certain situations. In this article, we’ll see how we can implement a simple but fast object mapper in C#.

    [ Also on InfoWorld: The best new features in C# 12 ]

    Create a console application project in Visual Studio

    First off, let’s create a .NET Core console application project in Visual Studio. Assuming Visual Studio 2022 is installed in your system, follow the steps outlined below to create a new .NET Core console application project.

    To read this article in full, please click here


    Značky: #C#, #Rozne

    • In chevron_right

      How to use primary constructors in C# 12

      pubsub.slavino.sk / infoworldcom · Thursday, 4 January - 10:00 edit

    One of the striking new features in C# 12 is the support for primary constructors. The concept of primary constructors is not new. Several programming languages including Scala, Kotlin, and OCaml provide support for integrating constructor parameters directly at the place where you declare your class.

    In this article, we’ll take a close look at primary constructors and how we can work with them in C# 12. To run the code examples provided in this article, you should have Visual Studio 2022 installed in your system. If you don’t already have a copy, you can download Visual Studio 2022 here .

    To read this article in full, please click here


    Značky: #Rozne, #C#

    • In chevron_right

      How to use IEnumerable, ICollection, IList, and IQueryable in C#

      pubsub.slavino.sk / infoworldcom · Thursday, 21 December - 10:00 edit

    The C# programming language provides excellent support for working with collections of data. C# includes several classes and interfaces that can help you query collections of data efficiently. The most commonly used interfaces for working with collections are IEnumerable, ICollection, IList, and IQueryable.

    In this article we will examine each of these interfaces and discuss how we can work with them in .NET 8 , illustrated with code examples.

    Create a console application project in Visual Studio

    First off, let’s create a .NET Core console application project in Visual Studio. Assuming Visual Studio 2022 is installed in your system, follow the steps outlined below to create a new .NET Core console application project.

    To read this article in full, please click here


    Značky: #C#, #Rozne

    • wifi_tethering open_in_new

      This post is public

      www.infoworld.com /article/3711805/how-to-use-ienumerable-icollection-ilist-and-iqueryable-in-c-sharp.html

    • In chevron_right

      How to use request decompression in ASP.NET Core 7

      pubsub.slavino.sk / infoworldcom · Thursday, 27 April, 2023 - 09:00 edit

    Minimal APIs in ASP.NET Core allow you to easily create RESTful APIs with minimal code and configuration. No matter what type of API we build, it is always important to minimize the amount of data transferred over the network, which saves bandwidth and improves the responsiveness of the app. We do this by compressing the payloads of both requests and responses.

    Of course, that means we must decompress those payloads at the other end. In ASP.NET Core 7, request decompression is supported out of the box: You can now use the new request decompression middleware to enable your API endpoints to accept requests that have compressed data.

    This article examines how you can work with request compression and decompression in ASP.NET Core 7 Minimal APIs. (Note that we discussed response compression in ASP.NET Core in a previous article.) To use the code examples provided in this article, you should have Visual Studio 2022 installed in your system. If you don’t already have a copy, you can download Visual Studio 2022 here .

    To read this article in full, please click here


    Značky: #C#, #Rozne

    • chevron_right

      Unix legend, who owes us nothing, keeps fixing foundational AWK code

      news.movim.eu / ArsTechnica · Tuesday, 23 August, 2022 - 17:50 · 1 minute

    Brian Kernighan speaking onstage.

    Enlarge / Brian Kernighan speaking at a tribute to his Bell Labs coworker and The C Programming Language co-author Dennis Ritchie in 2012. Ritchie's visage in dominoes is behind Kernighan. (credit: Ben Lowe/Flickr )

    A Princeton professor, finding a little time for himself in the summer academic lull, emailed an old friend a couple months ago. Brian Kernighan said hello, asked how their US visit was going, and dropped off hundreds of lines of code that could add Unicode support for AWK, the text-parsing tool he helped create for Unix at Bell Labs in 1977.

    "I have tested this a fair amount but clearly more tests are needed," Kernighan wrote in the email, posted in late May as a kind of pseudo-commit on the onetrueawk repo by longtime maintainer Arnold Robbins. "Once I figure out how ... I will try to submit a pull request. I wish I understood git better, but in spite of your help, I still don't have a proper understanding, so this may take a while."

    Kernighan is the "K" in AWK , a special-purpose language for extracting and manipulating language that was key to Unix's pipeline features and interoperability between systems. A working awk function (AWK is the language, awk the command to invoke it) is critical to both Standard UNIX Specification and IEEE POSIX certification for interoperability. There are countless variants of awk —including modern derivations with support for Unicode—but "One True AWK," sometimes known as nawk , is a kind of canonical version based on Kernighan's 1985 book The AWK Programming Language and his subsequent input.

    Read 5 remaining paragraphs | Comments

    • In chevron_right

      How to work with Azure Functions in C#

      pubsub.slavino.sk / infoworldcom · Thursday, 28 April, 2022 - 10:00 edit

    Azure Functions is the serverless compute offering in the Microsoft Azure cloud. Essentially, “serverless” means you don’t even need a virtual machine to run an Azure Function. Azure Functions are just an implementation of platform as a service (PaaS), one that is based on an event-driven programming model. This article presents an introduction to Azure Functions, why they are useful, and how we can work with them.

    As there are no servers that you have to manage, Azure Functions can scale automatically, and you pay only for the time your code runs. You can leverage Azure Functions for event processing in real time, or for scheduled data processing jobs, such as scheduled data backup or data clean-up. You can even use Azure Functions as serverless back ends to mobile applications.

    To read this article in full, please click here


    Značky: #C#, #Rozne

    • In chevron_right

      Build desktop and mobile UIs with Blazor Hybrid apps

      pubsub.slavino.sk / infoworldcom · Wednesday, 27 April, 2022 - 10:00 edit

    Microsoft’s commitment to a cross-platform world is perhaps one of the biggest changes to its development platform during the past few years. Its purchase of Xamarin kickstarted a sea change that’s brought us to today’s Visual Studio–powered development environment that brings in GitHub at one end and the cross-platform .NET 6 at the other, with applications that run at scale in cloud Kubernetes systems and on mobile devices.

    Recently I looked at the development of the successor to Xamarin’s cross-platform Forms UI tools: .NET’s Multiplatform App UI or MAUI. Related to that is another new Microsoft UI technology designed to bring those at-scale web applications into your devices and onto your desktop. Building on top of the flexible Blazor web UI framework , Blazor Hybrid mixes the two technologies to give you a way of building UIs that spans more than desktop and mobile, adding support for the web with natively rendered controls on all platforms .

    To read this article in full, please click here


    Značky: #Rozne, #C#

    • In chevron_right

      C# 11 previews raw string literals, dumps parameter null checking

      pubsub.slavino.sk / infoworldcom · Thursday, 21 April, 2022 - 10:00 edit

    Microsoft’s planned C# 11 language upgrade is set to feature capabilities such as raw string literals and checked user-defined operators, along with better performance.

    C# 11 is due to arrive as a production release with the .NET 7 software development platform in November. Runtime performance is improved in C# 11 by caching of static method groups, rather than creating fresh delegate instances. This will improve application performance particularly for ASP.NET. Developers get the benefit of this feature with no effort on their part.

    [ Also on InfoWorld: What’s new in Microsoft .NET 6 ]

    Raw string literals in C# 11, which start and end with three double-quotes ( """ ), promise to make it easier to work with literals that contain characters that would otherwise need to be escaped. Raw string literals have no escaping, so all characters are considered content and included in the string. The sequence \t is output as a backslash and the character t, not as the tab character.

    To read this article in full, please click here


    Značky: #Rozne, #C#