Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
Singapore V2Ray VPN for Tunneling
hu KANNA
Updated:
Monday at 9:03 PM
Plan your Crypto & Forex entries before you take the trade
romeshnonis
Updated:
Monday at 3:20 AM
RHCSA, RHCE, AWS, Docker, Kubernetes Training
Sanjeewani95
Updated:
Sep 8, 2026
🛡️ Kaspersky Antivirus – 1 Year / 1 Device | Rs. 2,300 | Only 9 Left
KSPathirana
Updated:
Sep 7, 2026
Ad icon
Professional CCTV Installation Service
Techguy231
Updated:
Sep 6, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
Need Help With a Simple C# Program!
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="TΞΞNSTAR™" data-source="post: 6833255" data-attributes="member: 88129"><p>Guys ..</p><p></p><p>Im a newbie to C# and I need some guidance to rectify this confusion I'm facing. </p><p></p><p>What I wanted to create is a simple calculation and I can do it in the Main method it self. But I Created a Class named "add" so that I can call it to in the main method. </p><p></p><p>I initialized int i and j in the main program and why cant I use it in the add class?</p><p></p><p>Below is my code snippet </p><p></p><p>[CODE]</p><p>using System;</p><p></p><p></p><p>namespace AddMinusDivideMultiply</p><p>{</p><p> class Program</p><p> {</p><p> public static void Main(string[] args)</p><p> {</p><p> Console.Write("Please Enter The First Number :");</p><p> string temp = Console.ReadLine();</p><p> int i = Int32.Parse(temp);</p><p></p><p> Console.Write("Please Enter The Second Number :");</p><p> temp = Console.ReadLine();</p><p> int j = Int32.Parse(temp);</p><p></p><p> Addition.Add();</p><p> }</p><p> }</p><p></p><p> class Addition</p><p> {</p><p> public static void Add()</p><p> {</p><p> int add;</p><p> add = i + j;</p><p> Console.WriteLine("The Addition Of The First and The Second Number is {0}", add);</p><p> }</p><p> }</p><p>}</p><p></p><p>[/CODE]Error which I'm getting is</p><p></p><p>Please explain.. Thank you in advance...</p></blockquote><p></p>
[QUOTE="TΞΞNSTAR™, post: 6833255, member: 88129"] Guys .. Im a newbie to C# and I need some guidance to rectify this confusion I'm facing. What I wanted to create is a simple calculation and I can do it in the Main method it self. But I Created a Class named "add" so that I can call it to in the main method. I initialized int i and j in the main program and why cant I use it in the add class? Below is my code snippet [CODE] using System; namespace AddMinusDivideMultiply { class Program { public static void Main(string[] args) { Console.Write("Please Enter The First Number :"); string temp = Console.ReadLine(); int i = Int32.Parse(temp); Console.Write("Please Enter The Second Number :"); temp = Console.ReadLine(); int j = Int32.Parse(temp); Addition.Add(); } } class Addition { public static void Add() { int add; add = i + j; Console.WriteLine("The Addition Of The First and The Second Number is {0}", add); } } } [/CODE]Error which I'm getting is Please explain.. Thank you in advance... [/QUOTE]
Insert quotes…
Verification
Winadiyakata thappara keeyak tibeda?
Post reply
Top
Bottom