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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 13, 2013, 12:33 AM EDT
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();
}
}
}
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 13, 2013, 12:42 AM EDT
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();
}
}
}
Hamid KhanRank #424 · 5.9K reputationPosted Aug 9, 2020, 10:36 AM EDT
om prakashRank #5,816 · 285 reputationPosted Aug 13, 2013, 12:40 AM EDT
Abwaank Khaliif18 reputationPosted Aug 13, 2013, 1:00 AM EDT
om prakashRank #5,816 · 285 reputationPosted Aug 15, 2013, 11:27 PM EDT
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 15, 2013, 11:40 PM EDT
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();
}
}
}