Makai Studio
Imi ‘Ike - Seeker Of Knowledge
Imi-?ike

Converting String to Int in a Method With C#

January 28, 2008 06:47 by jdelpay

In the sample below, I will show you how to convert a string to int inside a method 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace method001
{
    class Program
    {
        static int calculDob(int a)
        {
            int year = 2008 - a; //calculation
            return year; // the value being returned

        }
        static void Main(string[] args)
        {
            Console.WriteLine("How old are you? ");// asking for some data
            int age = Convert.ToInt16(Console.ReadLine());// convert the entry to a int type and assign the value to the age variable
            Console.WriteLine("You were born in: {0}",calculDob(age));

        }
    }
}

 


Visit:Makai Studio

AddThis Social Bookmark Button

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: ASP.Net
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

May 16. 2008 14:36