Main Content

Please wait...
Get File Size in C#. How to get a file size in bytes using C# using the FileInfo.Length property. The size of any file in bytes can be returned by the Length property of FileInfo Class. Following code returns the size of file: // To Get size of any file long FileSize = MyFile.Length; Console.WriteLine("File Size in Bytes: {0}", FileSize); Here, to run it we must import System.IO and System.Text namespaces in the project. Coding Implementation Here is the complete coding impl ....Read More

JIT(Just In Time) Compiler in .NET

JIT(Just In Time) Compiler in .NET As we know that .Net Framework supports various Microsoft .Net Languages and all them use a Common Language Runtime rather than using a separate runtime for single one of languages. So, when .NET Common Language is installed in a computer it can support any language that is Microsoft .NET compatible. So, the purpose of JIT Compiler is to convert the .NET Language into the native code which is CPU specific. First the source code is converted to Intermediate L ....Read More
If your self hosted application acquired memory and it's not released then (or your core application lead to system out of memory), the tips in this post will help you. Once on my application what I had seen at the time of high traffic the memory acquired by ASP.NET Core application is not free and the server is running out of memory. To fix this issue my team and me started to find the problem in the application and after some hour of profiling, what we had seen there is not a b ....Read More
How to Trim the string in Model in Aspnet core? Why trimming the text is important? Simply, because we don’t need any white space in a string. When you are doing any web project and implementing Rest API Service, we need to create a lot of forms, trimming every string value that the user supplied is time-consuming. So Here we have an easier and effective solution for the problem. First, we need the IModelBinder and IModelBinderProvider. Model Binder is now at a single place on inf ....Read More

Find prime porcupine number.

A prime number is an integer that is divisible by 1 an itself. A porcupine number is a prime number whose last digit is 9 and the next prime number that follows it also ends with the digit 9. For example 139 is a porcupine number because: It is prime It ends in a 9 The next prime number after it is 149 which also ends in 9. Note that 140, 141, 142, 143, 144, 145, 146, 147 and 148 are not prime so 149 is the next prime number after 139. Write a function name isproc() that take two inpu ....Read More

Find prime number between two range.

Write a function named prime count with a signature in int PrimeCount(int start, int end); the function print the prime number from the given range. Recall the prime is an integer greater than 1whose only integer factor is one or itself. if start is And end is reason 10 30 The prime between 10 to 30 are 11 ,13 ,17 ,19, 23 ,29. 11 29 The prime between 10 to 30 are 11 ,13 ,17 ,19, 23 ,29. 20 22 20,21,22 are all non-prime ....Read More

Finding Next Perfect Square using math function.

Write a function named nextPerfectSquare that returns the first perfect square that is greater that its integer argument. A perfect square is an integer that is equal to some integer squared. For example 16 is a perfect square because 16=4*4. However 15 is not a perfect square because there is no integer n such that 15=n*n. Examples:- n next perfect square 6 9 36 49 0 1 -5 0 Solution:- using System; namespace perfectSqua ....Read More

Check squareRoot of integer without using sqrt().

Write a function named isSquare that returns 1 if its integer is a square of some integer, otherwise it returns 0. Your function must not use any function or method (e.g.sqrt) that comes with a runtime library or class library! The signature of the functions: int isSquare(int n) Example: If n is return reason 4 1 Because ....Read More

.NET 5: One Framework, All Platforms and Open Source

.NET 5: One Framework, All Platforms and Open Source With the announcement of new version of .NET, we are expected to receive the new version around November 2020 and the preview available around the first half of 2020 . There will be no .NET core in coming days, it is going to be only .NET and .NET 5 in the future of .NET .Dotnet 5 is a single platform that will work for building software of all kinds, all platforms and devices.Today there are two versions of .NET that is .NET framework and ....Read More

Simple way to handle HTTP status error in ASP.NET core

You can simply handle http status error like HTTP 404 error and any other http status error in ASP .NET by using this simple solution. HTTP 404 is one of the must common error in ASP .NET when the requested error is not found . We can solve the problem by adding some code in the configure() method in Startup.cs class which is also the entry point for the application itself. In the configure function we define and add a custom middleware with ‘app.Use’ which will check for status c ....Read More