473,378 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

working with user created classes

hi everyone.. i have a problem that i couldnt find the answer through the
web..
maybe i am asking the wrong question.. but here comes my problem..

----------------------------------

using System;

namespace NeuralNetwork

{

public class SCNeuralNetwork

{

private double activation;

private double treshold;

public SCNeuralNetwork()

{

Random random = new Random();

activation = random.NextDouble();

treshold = random.NextDouble();

}

public SCNeuralNetwork(double act,double tre)

{

this.Activation = act;

this.Treshold = tre;

}

public double Activation

{

set{activation = value;}

get{return activation;}

}

public double Treshold

{

set{treshold = value;}

get{return treshold;}

}
}

}

everything works good but when i try the call my class from main program
like this:

mainprogram.SCNeuralnetwork []network = new mainprogram.SCNeuralnetwork[10];

network[0].Activation = 10;

when i try to do something like this program throws "Object reference not
set to an instance of an object." exception.

what am i doing wrong? i cant set or read the values from the aray of
classes..

p.s: it works fine when i create the classs like ;

mainprogram.SCNeuralnetwork network = new mainprogram.SCNeuralnetwork();

thanks for helping and spending your time.. have a nice day..


Nov 16 '05 #1
2 1047
SB
When you create an array, you are basically only creating an array that will
hold x items. Each item is not created for you...you have to do that
explicitly.

try:
mainprogram.SCNeuralnetwork[] network = new mainprogram.SCNeuralnetwork[10];
for (int i = 0; i < network.Length; i++)
{
network[i] = new SCNeuralnetwork();
}

-sb

"Serdar C" <se*****@interaktif.gen.tr> wrote in message
news:Oa*************@TK2MSFTNGP10.phx.gbl...
hi everyone.. i have a problem that i couldnt find the answer through the
web..
maybe i am asking the wrong question.. but here comes my problem..

----------------------------------

using System;

namespace NeuralNetwork

{

public class SCNeuralNetwork

{

private double activation;

private double treshold;

public SCNeuralNetwork()

{

Random random = new Random();

activation = random.NextDouble();

treshold = random.NextDouble();

}

public SCNeuralNetwork(double act,double tre)

{

this.Activation = act;

this.Treshold = tre;

}

public double Activation

{

set{activation = value;}

get{return activation;}

}

public double Treshold

{

set{treshold = value;}

get{return treshold;}

}
}

}

everything works good but when i try the call my class from main program
like this:

mainprogram.SCNeuralnetwork []network = new
mainprogram.SCNeuralnetwork[10];

network[0].Activation = 10;

when i try to do something like this program throws "Object reference not
set to an instance of an object." exception.

what am i doing wrong? i cant set or read the values from the aray of
classes..

p.s: it works fine when i create the classs like ;

mainprogram.SCNeuralnetwork network = new mainprogram.SCNeuralnetwork();

thanks for helping and spending your time.. have a nice day..

Nov 16 '05 #2
ah.. thank you for helping!.. its working now :)
"SB" <st********@yahoo.com> wrote in message
news:uk**************@TK2MSFTNGP15.phx.gbl...
When you create an array, you are basically only creating an array that will hold x items. Each item is not created for you...you have to do that
explicitly.

try:
mainprogram.SCNeuralnetwork[] network = new mainprogram.SCNeuralnetwork[10]; for (int i = 0; i < network.Length; i++)
{
network[i] = new SCNeuralnetwork();
}

-sb

"Serdar C" <se*****@interaktif.gen.tr> wrote in message
news:Oa*************@TK2MSFTNGP10.phx.gbl...
hi everyone.. i have a problem that i couldnt find the answer through the web..
maybe i am asking the wrong question.. but here comes my problem..

----------------------------------

using System;

namespace NeuralNetwork

{

public class SCNeuralNetwork

{

private double activation;

private double treshold;

public SCNeuralNetwork()

{

Random random = new Random();

activation = random.NextDouble();

treshold = random.NextDouble();

}

public SCNeuralNetwork(double act,double tre)

{

this.Activation = act;

this.Treshold = tre;

}

public double Activation

{

set{activation = value;}

get{return activation;}

}

public double Treshold

{

set{treshold = value;}

get{return treshold;}

}
}

}

everything works good but when i try the call my class from main program
like this:

mainprogram.SCNeuralnetwork []network = new
mainprogram.SCNeuralnetwork[10];

network[0].Activation = 10;

when i try to do something like this program throws "Object reference not set to an instance of an object." exception.

what am i doing wrong? i cant set or read the values from the aray of
classes..

p.s: it works fine when i create the classs like ;

mainprogram.SCNeuralnetwork network = new mainprogram.SCNeuralnetwork();

thanks for helping and spending your time.. have a nice day..


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
4
by: Richard | last post by:
All, I have coded an Outlook automation Addin in C# and .NET. I created the project using the Extensibility wizard. The Addin installs and runs Ok on my machine. However I am unable to...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
8
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
3
by: Matt | last post by:
I am in the process of creating a custom .NET object (this is my first one). I have created a few classes and some of them are collections. When I try to iterate through a collection I receive the...
4
by: aaragon | last post by:
Hello everyone. I'm reading Andrei's Alexandrescu's book on Modern C++ Design and I decided to implemente in my research code the use of policy classes. My objective is to abstract the storage of...
2
by: Annie | last post by:
Hello guys, I have set the MEMBERSHIP, ROLEMANAGER and PROFILE in my config file as below. I just want to use my own sql server 2000 table instead of MSDB.
30
by: Yorian | last post by:
Hey, Although I've been using classes and object for quite a while now I've never actually programmed proper OO code yet. It ofcourse depends on what you call proper OO code. I have been...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.