enter 1st name:prakash
enter 2nd name: om
your name:prakshom
how can i do this in console application...
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Aug 13, 2013, 4:33 AM
ex:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IfExample
{
class Class3
{
static void Main()
{
Console.WriteLine("Enter your 1st name");
string s = Console.ReadLine();
Console.WriteLine("Enter your last name");
string s2 = Console.ReadLine();
Console.WriteLine("your full name :");
Console.WriteLine(s+" "+s2);
Console.ReadLine();
}
}
}
Hamid KhanPosted Aug 9, 2020, 2:36 PM
Sanjeeb LenkaPosted Aug 16, 2013, 3:40 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IfExample
{
class joinstring
{
string A, B;
public joinstring(string X, string Y)
{
A = X;
B = Y;
}
public void Print()
{
Console.WriteLine("your full name :");
Console.WriteLine(A + " " + B);
}
static void Main()
{
Console.WriteLine("Enter your 1st name");
string s = Console.ReadLine();
Console.WriteLine("Enter your last name");
string s2 = Console.ReadLine();
joinstring obj = new joinstring(s, s2);
obj.Print();
Console.ReadLine();
}
}
}
om prakashPosted Aug 16, 2013, 3:27 AM
Abwaank KhaliifPosted Aug 13, 2013, 5:00 AM
Sanjeeb LenkaPosted Aug 13, 2013, 4:42 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace IfExample
{
class DateTimeExtensions
{
public string ToAgeString( DateTime dob)
{
DateTime dt = DateTime.Now;
int days = dt.Day - dob.Day;
if (days < 0)
{
dt = dt.AddMonths(-1);
days += DateTime.DaysInMonth(dt.Year, dt.Month);
}
int months = dt.Month - dob.Month;
if (months < 0)
{
dt = dt.AddYears(-1);
months += 12;
}
int years = dt.Year - dob.Year;
return string.Format("{0} year{1}, {2} month{3} and {4} day{5}",
years, (years == 1) ? "" : "s",
months, (months == 1) ? "" : "s",
days, (days == 1) ? "" : "s");
}
static void Main()
{
DateTimeExtensions obj = new DateTimeExtensions();
Console.WriteLine("Enter your date of birth in mm/dd/yyyy format to calculate age");
DateTime dob = DateTime.Parse(Console.ReadLine());
string s = obj.ToAgeString(dob);
Console.WriteLine(s);
Console.ReadLine();
}
}
}
om prakashPosted Aug 13, 2013, 4:40 AM