Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project,
which includes a class. I have added the project to the main application but
I can't seem to create an instance of the class in the main application. The
class is called MyFirstClass, with namespace MyFirstClass. What steps do I
need to take to create an instance of the class within the main windows
application?
Thanks in advance
Geoff 10 1126
You can change the namespace of your class to correspond with the namespace
of your other project so both assemblies become of one namespace.
Then, if you use myClass classOfMine = new myClass(); it should work.
"Geoff Jones" wrote: Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
Make sure your namespaces in both files match up. If not then you will have to
use the fully qualified name.
When you say "I have added the project to the main application" I'll assume you
meant "I have added the class to the main application".
If they are two different projects then you'll need to add a reference from one
to the other.
Try
MyFirstClass.MyFirstClass instance = new MyFirstClass.MyFirstClass();
- john
Geoff Jones <no********@email.com> wrote: Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
I get the message:
; expected
?
Geoff
"Vincent" <Vi*****@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com... You can change the namespace of your class to correspond with the namespace of your other project so both assemblies become of one namespace. Then, if you use myClass classOfMine = new myClass(); it should work.
"Geoff Jones" wrote:
Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
Hi John
This is very puzzling.
They are two different projects. I have now added a reference to the main
application for the other class. I have tried your suggestion and used the
fully qualified name but I still get the same error i.e. ; expected.
Geoff
<co******@tetra.xionheights.net> wrote in message
news:T%***************@fe37.usenetserver.com... Make sure your namespaces in both files match up. If not then you will have to use the fully qualified name.
When you say "I have added the project to the main application" I'll assume you meant "I have added the class to the main application".
If they are two different projects then you'll need to add a reference from one to the other.
Try MyFirstClass.MyFirstClass instance = new MyFirstClass.MyFirstClass();
- john
Geoff Jones <no********@email.com> wrote: Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
If you use Visual Studio you can double click the message and it will go to
where this error is located. You can then adjust it. (You probably forgot to
enter a ";" somewhere, where it was expected.)
For instance
myClass cls = new myClass() // will generate an error
myClass cls = new myClass(); // won't generate that error
"Geoff Jones" wrote: I get the message:
; expected
?
Geoff
"Vincent" <Vi*****@discussions.microsoft.com> wrote in message news:64**********************************@microsof t.com... You can change the namespace of your class to correspond with the namespace of your other project so both assemblies become of one namespace. Then, if you use myClass classOfMine = new myClass(); it should work.
"Geoff Jones" wrote:
Hiya
I hope somebody can help me with this relatively simple beginner question:
I have created a windows Application in C#. I have also created a project, which includes a class. I have added the project to the main application but I can't seem to create an instance of the class in the main application. The class is called MyFirstClass, with namespace MyFirstClass. What steps do I need to take to create an instance of the class within the main windows application?
Thanks in advance
Geoff
Can you post a clip of your code? Maybe it's just a simple syntax error somewhere.
Geoff Jones <no********@email.com> wrote: Hi John
This is very puzzling.
They are two different projects. I have now added a reference to the main application for the other class. I have tried your suggestion and used the fully qualified name but I still get the same error i.e. ; expected.
Geoff
Hi Vincent
Yep, tried that. I've written
myClass cls = new myClass();
and it still gives the same error message.
Geoff
"Vincent" <Vi*****@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com... If you use Visual Studio you can double click the message and it will go to where this error is located. You can then adjust it. (You probably forgot to enter a ";" somewhere, where it was expected.) For instance myClass cls = new myClass() // will generate an error myClass cls = new myClass(); // won't generate that error
"Geoff Jones" wrote:
I get the message:
; expected
?
Geoff
"Vincent" <Vi*****@discussions.microsoft.com> wrote in message news:64**********************************@microsof t.com... > You can change the namespace of your class to correspond with the > namespace > of your other project so both assemblies become of one namespace. > Then, if you use myClass classOfMine = new myClass(); it should work. > > "Geoff Jones" wrote: > >> Hiya >> >> I hope somebody can help me with this relatively simple beginner >> question: >> >> I have created a windows Application in C#. I have also created a >> project, >> which includes a class. I have added the project to the main >> application >> but >> I can't seem to create an instance of the class in the main >> application. >> The >> class is called MyFirstClass, with namespace MyFirstClass. What steps >> do >> I >> need to take to create an instance of the class within the main >> windows >> application? >> >> Thanks in advance >> >> Geoff >> >> >>
AHHHHHHHHHHHHHHHH!!!
Got it! I'd written
myClass cls = New myClass; // Note capital "N"
Strange, I would have thought the environment would allow both?
D'OH!
Thanks guys
"Vincent" <Vi*****@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com... If you use Visual Studio you can double click the message and it will go to where this error is located. You can then adjust it. (You probably forgot to enter a ";" somewhere, where it was expected.) For instance myClass cls = new myClass() // will generate an error myClass cls = new myClass(); // won't generate that error
"Geoff Jones" wrote:
I get the message:
; expected
?
Geoff
"Vincent" <Vi*****@discussions.microsoft.com> wrote in message news:64**********************************@microsof t.com... > You can change the namespace of your class to correspond with the > namespace > of your other project so both assemblies become of one namespace. > Then, if you use myClass classOfMine = new myClass(); it should work. > > "Geoff Jones" wrote: > >> Hiya >> >> I hope somebody can help me with this relatively simple beginner >> question: >> >> I have created a windows Application in C#. I have also created a >> project, >> which includes a class. I have added the project to the main >> application >> but >> I can't seem to create an instance of the class in the main >> application. >> The >> class is called MyFirstClass, with namespace MyFirstClass. What steps >> do >> I >> need to take to create an instance of the class within the main >> windows >> application? >> >> Thanks in advance >> >> Geoff >> >> >>
Geoff,
The first thing when you have added a project to your project which holds a
class libary is setting a reference to it with the references and than the
tab "projects". Than that extra project(s) should be showed there and you
can select it.
Than you can set an import to that (not necessary however easy)
I hope that this is what you are after.
Cor
Hiya
Sorted it out Ta
I'd written New instead of new - D'OH!
Geoff
<co******@tetra.xionheights.net> wrote in message
news:7x***************@fe37.usenetserver.com... Can you post a clip of your code? Maybe it's just a simple syntax error somewhere.
Geoff Jones <no********@email.com> wrote: Hi John
This is very puzzling.
They are two different projects. I have now added a reference to the main application for the other class. I have tried your suggestion and used the fully qualified name but I still get the same error i.e. ; expected.
Geoff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: hzgt9b |
last post by:
When adding my VB .NET solution (with two sub-projects) the folder structure
in VSS gets an extra level of folders...
For example, here's the structure of the solution on my C:\...
|
by: Wysiwyg |
last post by:
Is there any way to add an embedded resource to a project without copying it
to the project's directory? I have shared resources and don't want each
project using the images, xml files, etc. to...
|
by: Simon Jefferies |
last post by:
Hello,
I am trying to add an item to a checked list box, like:
clbList.Items.add("Hello",true)
I get an error back:
Run-time exception thrown: System.ArgumentOutOfRangeException -...
|
by: UJ |
last post by:
I have a couple of files (type definitions, constants, ...) that I want to
use in multiple projects. How do I make it so that I have only one copy of
the file for multiple projects? If I do add...
|
by: _DS |
last post by:
The two obvious methods for ref'ing assemblies are:
Add a reference and 'Browse' for the actual DLL
OR
Add existing project to the solution, then add a ref to 'Project'.
1: I'd like to...
|
by: sukeshchand |
last post by:
How to create an event object in a dll without adding the dll into the project
ie.; i use CreateObject() to create an instance of an object in a dll without adding the dll into the project. it is ok...
|
by: =?Utf-8?B?TGVvbiBNYXluZQ==?= |
last post by:
In a database project in VS2005 (not a datadude project), I need to add about
3,000 stored procedure scripts to my 'Stored Procedures' folder. I've dropped
the scripts into the folder in my...
|
by: damonreid |
last post by:
Access 2003
Microsoft Windows XP Pro
Hey,
I am currently pulling my hair out here.
I have a Form for adding new projects to a database, the only problem is that when I close the form it doesn't...
|
by: Jason |
last post by:
Hello,
I am trying to utilitze the AJAX Control toolkit in my asp.net project. I
have added a reference to AjaxControlToolkit.dll, and in my page, added
these lines of code:
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |