Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Null Reference problems C#

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Sun Nov 22, 2009 12:45 am    Post subject: Null Reference problems C# Reply with quote

I got it when trying to initialize my array of sprites
(( the only one trowing me null is the sprite2D[] AllianceCharacters


declaration:
Code:
sprite2D[] AllianceCharacters;
static string Cardspath = Directory.GetCurrentDirectory() + "\\Content\\Cards";
string[] ActionBar = Directory.GetFiles(Cardspath + "\\ActionBar\\");
        string[] Equips = Directory.GetFiles(Cardspath + "\\ActionBar\\Equips");
        string[] CharactersAlliance = Directory.GetFiles(Cardspath + "\\Characters\\Alliance\\");
        string[] CharactersHorde = Directory.GetFiles(Cardspath + "\\Characters\\Horde\\");
        string[] CharactersMonster = Directory.GetFiles(Cardspath + "\\Characters\\Monster\\");

initialization:
Code:
for (int i = 0; i < CharactersAlliance.Length; i++)
            {

                AllianceCharacters[i] = new sprite2D(Content.Load<Texture2D>(Cardspath + "\\Characters\\Alliance\\" + CharactersAlliance[i]));
                AllianceCharacters[i].name = CharactersAlliance[i];

            }



//This is called at the beginning::
Code:
void FixNames()
        {
            int x, y, z, a, h, m;
           
            y = Equips.Length;
            z = ActionBar.Length;
            a = CharactersAlliance.Length;
            h = CharactersHorde.Length;
            m = CharactersMonster.Length;
           
            char[] xnb = { 'b', 'n', 'x', '.' };

            for (x = 0; x < y; x++)
            {
                Equips[x] = Path.GetFileName(Equips[x]);
                Equips[x] = Equips[x].TrimEnd(xnb);
            }
            for (x = 0; x < z; x++)
            {
                ActionBar[x] = Path.GetFileName(ActionBar[x]);
                ActionBar[x] = ActionBar[x].TrimEnd(xnb);
            }
            for (x = 0; x < a; x++)
            {
                CharactersAlliance[x] = Path.GetFileName(CharactersAlliance[x]);
                CharactersAlliance[x] = CharactersAlliance[x].TrimEnd(xnb);
            }
            for (x = 0; x < h; x++)
            {
                CharactersHorde[x] = Path.GetFileName(CharactersHorde[x]);
                CharactersHorde[x] = CharactersHorde[x].TrimEnd(xnb);
            }
            for (x = 0; x < m; x++)
            {
                CharactersMonster[x] = Path.GetFileName(CharactersMonster[x]);
                CharactersMonster[x] = CharactersMonster[x].TrimEnd(xnb);
            }
        }



any idea on what could be making it fail ?


EDIT:: forget it,.. in the end I figured out myself...
Back to top
View user's profile Send private message MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Sun Nov 22, 2009 4:27 am    Post subject: Reply with quote

Stop treating C# like a purely procedural imperative programming language. It is object oriented, treat it as such. I suggest you actually learn the language before you continue this project, as the last few posts you've made in this section show you don't even understand the basic constructs.
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Sun Nov 22, 2009 4:45 am    Post subject: Reply with quote

I'm making this project to learn, this is for self study mostly and my problem was that yeah I'm not used yet to the system, but I think its all about practice.. I mean... I could solve the problem by myself by just looking at the code several times again and again.
Back to top
View user's profile Send private message MSN Messenger
Fendaril
Cheater
Reputation: 0

Joined: 08 Nov 2009
Posts: 27

PostPosted: Sun Nov 22, 2009 9:25 am    Post subject: Reply with quote

Quote:
Stop treating C# like a purely procedural imperative programming language. It is object oriented, treat it as such. I suggest you actually learn the language before you continue this project, as the last few posts you've made in this section show you don't even understand the basic constructs.


She wouldn't post here if she was a c# master. Stop trolling.
Back to top
View user's profile Send private message
gogodr
I post too much
Reputation: 125

Joined: 19 Dec 2006
Posts: 2041

PostPosted: Sun Nov 22, 2009 12:00 pm    Post subject: Reply with quote

Fendaril wrote:
Quote:
Stop treating C# like a purely procedural imperative programming language. It is object oriented, treat it as such. I suggest you actually learn the language before you continue this project, as the last few posts you've made in this section show you don't even understand the basic constructs.


She wouldn't post here if she was a c# master. Stop trolling.

I'm a he .... .____.;;

__ BTW


Link
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites