How to add one year value in string in asp.net c#

 In this article, we learn about how to add one year in string value, as we know that we can add on year in asp.net very easily to using Addyears class but we can ’t use this class on string so first we need  convert string to date time ,then we can add  one year very easily . It not about one year  if we want more year then we just need to put  AddYears(int value). Ex{(AddYears(5))} As we required we change the integer value. 


Code behind(c#):-

         string  strdate = "23/01/2015" ;
string date = Convert.ToDateTime(strdate).AddYears(1).ToShortDateString();
        Label1.Text = date;

Out-put:-



How to add one year value in string in asp.net c# How to add one year value in string in asp.net c# Reviewed by NEERAJ SRIVASTAVA on 9:41:00 AM Rating: 5

1 comment:

  1. Really awesome....great article
    I have one doubt why we use linq?
    I mean if there is connection possible using sql server code then why we use big linq code..
    Thank you!

    ReplyDelete

Powered by Blogger.