Topic: ASP.NET

C# Calculate Age Tutorial with Examples 0

C# Calculate Age Tutorial with Examples

Today, We want to share with you C# Calculate Age Tutorial with Examples.
In this post we will show you How to Calculate age from Date of Birth in C#, hear for Calculating age from date of birth – C# we will give you demo and example for implement.
In this post, we will learn about C# Calculate age from Date of Birth with an example.

calculate someone’s age in C#

In this post, we will learn about how to calculate someone’s age in C# with an example.

My Paka Knowledgeable Ideas, Tips and Tricks, Useful Content, Jobs, Technology, Earn Money, gmail creation, skype, yahoo and more useful things.

Now in this post, I will explain how to calculate someone’s age in C# with appropriate example.

Now create Console Application in Visual Studio and write below lines of code in it.

using System;
using System.Collections;
using System.Collections.Generic;
namespace PakaInfo
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime _BirthDate = new DateTime(1991, 10, 29);
            DateTime _Now = new DateTime(2017, 12, 23);
            Console.WriteLine(string.Format("Age : {0}", GetAge(_BirthDate, _Now)));
            Console.ReadKey();
        }

        public static int GetAge(DateTime p_BirthDate, DateTime p_Now)
        {
            int age = p_Now.Year - p_BirthDate.Year;

            if (p_Now.Month < p_BirthDate.Month || (p_Now.Month == p_BirthDate.Month && p_Now.Day < p_BirthDate.Day))
                age--;

            return age;
        }
    }
}

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about C# Calculate Age Tutorial.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

We hope This Post can help you…….Good Luck!.

Difference Between Managed and Unmanaged Code in C#.NET 0

Difference Between Managed and Unmanaged Code in C#.NET

Today, We want to share with you Difference Between Managed and Unmanaged Code in C#.NET.In this post we will show you Managed code and unmanaged code in .NET , hear for Difference between managed and unmanaged code we will give you demo and example for implement.In this post, we will learn about The Difference Between Managed and Unmanaged Code in .Net with an example.

Managed and Unmanaged Code in .Net

In this post,I will explain about Managed and Unmanaged Code in .Net

Now in this post, I will explain about Managed and Unmanaged Code in .Net

Managed Code

In simple words the code which is executed by CLR (Common Language Runtime) is called Managed Code, any application which is developed in .Net framework is going to work under CLR, the CLR internally uses the Garbage Collector to clear the unused memory and also used the other functionalities like CTS, CAS etc.

Unmanaged Code

The unmanaged code is cnceptually developed using some other languages (other than .Net Framework), so it uses its own language runtime to execute the applications. The application runtime will take care of its memory management, security and other thing

Even if we do not install .Net framework the unmanaged code will work properly as it is not depending on the CLR.

It is possible to run unmanaged code using managed code by using appropriate commands, but even if we run the unmanaged application using .Net code the CLR is not having control to run that application, the application uses its own runtime to execute.

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Difference between managed and unmanaged code
.I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Get Dynamically connection string in app.config file c# 0

Get Dynamically connection string in app.config file c#

Today, We want to share with you Get Dynamically connection string in app.config file c#.In this post we will show you dynamic connection string in c# windows application, hear for how to get connectionstring from app config in c# class library we will give you demo and example for implement.In this post, we will learn about how to get connection string from app.config in vb.net windows application with an example.

Now in this post, I will explain Read connectionstring from app.config c# with appropriate example.

c# – Get connection string from App.config

Write below lines of ASP.NET MVC Web Configuration code to read connection string from app.configue

string _ConnectionString = System.Configuration.ConfigurationManager.AppSettings[key];

Dynamic connection string in c# windows application

First of all just Add a reference simple of System.Configuration to your main page.

using System.Configuration;

app.config fetch the data connection string as follow.

string conStr = ConfigurationManager.ConnectionStrings["pakainfo"].ToString();

How to get Connection String from App.Config in C#

Using the Code

var connectionString=ConfigurationManager.ConnectionStrings["pakainfoManagements"].ConnectionString;

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Read (Get) Connection String from App.Config file using C# and VB.Net.I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Remove Special Characters from String using C# 0

Remove Special Characters from String using C#

Today, We want to share with you Remove Special Characters from String using C#.
In this post we will show you replace special characters in c#, hear for Trimming and Removing Characters from Strings in C# .NET we will give you demo and example for implement.
In this post, we will learn about C# – Best way to remove special All characters from a string with an example.

Remove Special Characters from String using C#

There are the Following The simple About Remove Special Characters from String using C# Full Information With Example and source code.

As I will cover this Post with live Working example to develop C# Program to remove special characters from a String , so the some major files and Directory structures for this example is following below.

  • Default.aspx.cs

Remove Special Characters from the Given String using C#

Default.aspx.cs

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as Default.aspx.cs.





    <title>Remove Special All Characters from the Given String using C#</title>


    <form id="form1">
        <div>
            <h2>How to remove All special characters from a string in asp.net c#</h2>
            <table style="width: 80%">
                <tr>
                    <td><b>C# Remove Special Characters from the Given String using regex:</b>
                        <br />
                        
                    </td>
                    <td></td>
                </tr>
                <tr>
                    <td>
                        <br />
                        <b>C# Remove Special Characters from the Given String using Replace():</b>
                        <br />
                        
                    </td>
                    <td></td>
                </tr>
            </table>
        </div>
    </form>


using System;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // remove specific characters from String using C#
        FirstLblDisplay.Text = SpecialCharRemove("[email protected]#string.com");
        secondLblDisplay.Text = SpecialChaRegexrRemove("[email protected]#string.com");

    }

    protected string SpecialChaRegexrRemove(string param)
    {
        return param = System.Text.RegularExpressions.Regex.Replace(param, "[^a-zA-Z0-9_]+", " ");
    }

    protected string SpecialCharRemove(string myInp)
    {
        return myInp.Replace("#", "")
            .Replace("", "")
            .Replace("'", "").Replace("\", "");
    }
}

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Remove Special Characters from String using C#.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Global.asax File in ASP.NET MVC Tutorial with Example 0

Global.asax File in ASP.NET MVC Tutorial with Example

Today, We want to share with you Global.asax File in ASP.NET MVC Tutorial with Example.In this post we will show you ASP.NET Global.asax file Example, hear for Exploring the Global.asax file in ASP.NET we will give you demo and example for implement.In this post, we will learn about Setting Up Global Objects with the global.asax File with an example.

Use of Global.asax in Asp.net

Introduction to Global.asax in Asp.net

What is the use of Global.asax file events in asp.net?

In this post, I will explain about the various event that is raised during the life cycle of a web application. Global.asax in Asp.net is used to specify an event handler for some application level event.

Global.asax Syntax

The Global.asax file is optional.

Global.asax in Asp.net handle any application or some times session events

Application_Init: This event Fires each time application initializes or is first called. It is invoked for all HttpApplication object instances.

Application_Disposed: This event Fires just before an application is destroyed. This is the suitable location for cleaning up any previously used resources.

Application_Error: This event Fires when an unhandled exception is encountered within the web application.So using this event we can write generic exception handler.

Application_Start: This event is raised when the application first starts up and the application domain is created. This event suitable for to set the rule that remains same till application runs.Ex, Routing rule, navigation tree etc.

Application_End: This event raised just before when web application ends.

Application_BeginRequest: This event is raised at the start of every request within the web application.

Application_EndRequest: This event is raised at the end of the web request and just before the objects are released and reclaimed. As a result, It’s a suitable event for cleanup code.

Application_PreRequestHandlerExecute: This event is raised before the ASP.NET page framework begins executing an event handler like a page or Web service.

Application_PostRequestHandlerExecute: This event is raised when the event handler finish the execution

Applcation_PreSendRequestHeaders: This event is raised when .net framework send the web HTTP header to a respected requesting client(i.e. Browser)

Application_PreSendContent: This event is raised before the ASP.NET page framework sends content to a requesting client (browser).

Application_AcquireRequestState: This event is raised when .net framework gets the current state of the current web request.

Application_ReleaseRequestState: This event is raised when the ASP.NET page framework completes execution of all event handlers. This results in all state modules to save their current state data.

Application_ResolveRequestCache: This event is raised when the ASP.NET web page framework completes the process of an authorization request.

Application_UpdateRequestCache: This event is raised when the ASP.NET page framework completes handler execution

Application_AuthenticateRequest: This event is raised when the security module has established the current user’s identity as valid. At this point, the user’s credentials have been validated.

Application_AuthorizeRequest: This event is raised when the security module has verified that a user can access resources.

Session_Start: This event is raised when a new user visits the application Web site.

Session_End: This event is raised when a user’s session times out, ends, or they leave the application Web site.

Example Global.asax implementation: C#




    static string _pagePath;

    void Application_Start(object sender, EventArgs e)
    {
        // source Code that simple ASP.net Global runs on application just startup
        _pagePath = Server.MapPath("~/Folder/Page.aspx");
    }

    // ...


Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about ASP.NET Global.asax File Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.