Error 1 'character': member names cannot be the same as their enclosing type
-
i'm teaching myself c#. i got through polymophism, pointers, linked lists, and data structures in C++ in college decades ago. however, I'm spacing on the easy shit it seems. Can someone help me out?
using System;
...
using System.Windows.Forms;namespace WindowsFormsApplication4
{
...public class character
{
protected Hashtable charSheet = new Hashtable();
protected Hashtable mutantStats = new Hashtable();
protected Hashtable mutantPower = new Hashtable();public void character() { charSheet.Add("Name", ""); ... mutantStats.Add("Tactics", ""); } public void character(string nm,int xp,int lvl,int str,int dex,int sta,int spe,int hea,int soa,int def) { charSheet.Add("Name", nm); ... mutantStats.Add("Defense", ""); } // constructors ...
-
i'm teaching myself c#. i got through polymophism, pointers, linked lists, and data structures in C++ in college decades ago. however, I'm spacing on the easy shit it seems. Can someone help me out?
using System;
...
using System.Windows.Forms;namespace WindowsFormsApplication4
{
...public class character
{
protected Hashtable charSheet = new Hashtable();
protected Hashtable mutantStats = new Hashtable();
protected Hashtable mutantPower = new Hashtable();public void character() { charSheet.Add("Name", ""); ... mutantStats.Add("Tactics", ""); } public void character(string nm,int xp,int lvl,int str,int dex,int sta,int spe,int hea,int soa,int def) { charSheet.Add("Name", nm); ... mutantStats.Add("Defense", ""); } // constructors ...
The error does tell you what it the problem is. Basically, you can't have a method name that's exactly the same as the class name. BTW - if you're using .NET 2 (or later), you have better options than Hashtable available to you. You may want to use the generic Dictionary class.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
i'm teaching myself c#. i got through polymophism, pointers, linked lists, and data structures in C++ in college decades ago. however, I'm spacing on the easy shit it seems. Can someone help me out?
using System;
...
using System.Windows.Forms;namespace WindowsFormsApplication4
{
...public class character
{
protected Hashtable charSheet = new Hashtable();
protected Hashtable mutantStats = new Hashtable();
protected Hashtable mutantPower = new Hashtable();public void character() { charSheet.Add("Name", ""); ... mutantStats.Add("Tactics", ""); } public void character(string nm,int xp,int lvl,int str,int dex,int sta,int spe,int hea,int soa,int def) { charSheet.Add("Name", nm); ... mutantStats.Add("Defense", ""); } // constructors ...
If
public void character()
andpublic void character(string nm,int xp,int lvl,int str,int dex,int sta,int spe,int hea,int soa,int def)
, are meant to be constructors remove the void. Leaving justpublic character(.....
. Constructors do not have a return type. :)Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
If
public void character()
andpublic void character(string nm,int xp,int lvl,int str,int dex,int sta,int spe,int hea,int soa,int def)
, are meant to be constructors remove the void. Leaving justpublic character(.....
. Constructors do not have a return type. :)Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”