| | |
Simple Question??
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
•
•
Join Date: Jun 2008
Posts: 27
Reputation:
Solved Threads: 0
C# Syntax (Toggle Plain Text)
namespace Empleados { class Empleados { private int edad; static private int numeroemp = 0; public Empleados(int edad) { this.edad = edad; Empleados.numeroemp ++; } public void mostrarInfo() { Console.WriteLine("el empleado tiene {0} años",edad ); Console.WriteLine("Numero de empleados creados {0} ", Empleados.obtenernumeEmpledos() ); } static void Main(string[] args) { int edad = 46; Empleados emp1 = new Empleados (edad); emp1.mostrarInfo(); Empleados emp2 = new Empleados(45); emp2.mostrarInfo(); } public static int obtenernumeEmpledos() { return numeroemp; } } }
this mi question if I run this program the results are
el empleado 1 tiene 46 años
numero de empleados creados 1
el empleado 2 tiene 45 años
numero de empleados creados 2
its ok but if i change
this code
C# Syntax (Toggle Plain Text)
public Empleados(int edad) { this.edad = edad; Empleados.numeroemp ++; }
C# Syntax (Toggle Plain Text)
public Empleados(int edad) { this.edad = edad; Empleados.numeroemp = + 1; }
the results are
el empleado 1 tiene 46 años
numero de empleados creados 1
el empleado 2 tiene 45 años
numero de empleados creados 1
why??
is no the same using ++ than + 1???
or i am wrong??
in your case it doesn't matter, which way you use to add 1. I suppose that you was talking about "+=" operator?
Let's see:
1. increasing numeroemp by 1.
2. which is the short version of this:
3. here you assign numeroemp by +1.
Let's see:
1.
c# Syntax (Toggle Plain Text)
Empleados.numeroemp++;
2.
c# Syntax (Toggle Plain Text)
Empleados.numeroemp += 1;
c# Syntax (Toggle Plain Text)
Empleados.numeroemp = Empleados.numeroemp + 1;
c# Syntax (Toggle Plain Text)
Empleados.numeroemp = + 1;
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
![]() |
Similar Threads
- A simple question about Ram (Motherboards, CPUs and RAM)
- simple question (C++)
- Quick Question: Is J# the same thing as Java? (Java)
- This has to be a simple question to answer. (Visual Basic 4 / 5 / 6)
- Simple question (Windows Servers and IIS)
- Simple Question (Linux Servers and Apache)
- A simple question about CMOS batteries (Motherboards, CPUs and RAM)
- XP Pro (re)activation question (Windows NT / 2000 / XP)
Other Threads in the C# Forum
- Previous Thread: code for validation(asp.net 3.5)
- Next Thread: palindrome
| Thread Tools | Search this Thread |
.net access algorithm angle array asp.net bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp database databasesearch datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net image input install interface java libraries list loop marshalbyrefobject math monodevelop mouseclick movingimage msword mysql operator path pause photoshop php picturebox pixelinversion platform post programming radians regex remoting richtextbox server sleep socket sql statistics string study system.servicemodel table tcpclientchannel text textbox thread time timer update usb usercontrol validation virtualization visualbasic visualstudio webbrowser winforms wpf wpfc# xml






