473,406 Members | 2,745 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,406 software developers and data experts.

Menu inside console application

Hello,

I have made a main class. (main.cs)
I also have made a menu class. (menu.cs)
The reason that I separate is is just for the code overview.

Now I want to see the menu calling from the main.
The problem is is that I don't want to make an object...
Is there not a way that I call the menu as procedure or function?

Thanks!


Nov 15 '05 #1
6 5300
More information about my question.

using System;
namespace Test {
static void Main(string[] args) {
// How to get my menu??? like showmenu();

}
}

using System;
namespace Test
{
/// <summary>
/// Summary description for showMenu.
/// </summary>
public showmenu() {
// some code
}
}
Must this be public? static?

I just want to access it like I said above.

Thanks!
Nov 15 '05 #2
"Arjen" <bo*****@hotmail.com> wrote:
Hello,

I have made a main class. (main.cs)
I also have made a menu class. (menu.cs)
The reason that I separate is is just for the code overview.

Now I want to see the menu calling from the main.
The problem is is that I don't want to make an object...
Is there not a way that I call the menu as procedure or function?

Thanks!


Well, you could implement static methods in your menu class and call
them, without having to make an instance of your menu class.

e.g.:

class Menu
{
public static StaticMethod()
{
}
}

//...

static void Main()
{
Menu.StaticMethod();
}
Nov 15 '05 #3
"Arjen" <bo*****@hotmail.com> wrote:
More information about my question.

using System;
namespace Test {
static void Main(string[] args) {
// How to get my menu??? like showmenu();

}
}

using System;
namespace Test
{
/// <summary>
/// Summary description for showMenu.
/// </summary>
public showmenu() {
// some code
}
}


You can't do that in C# -- namespaces are for holding classes only.

You'd have to do something like this instead:

namespace Test
{

public class Menu
{
public static Show()
{
}
}

}

Note that the name has changed from "ShowMenu" to "Show", since "Show"
is implemented in the "Menu" class.

Then call this static method with: Menu.Show();

<snip>
Nov 15 '05 #4
C# doesn't knows functions, procedures and contructors?

Thanks!


"C# Learner" <cs****@learner.here> schreef in bericht
news:iq********************************@4ax.com...
"Arjen" <bo*****@hotmail.com> wrote:
More information about my question.

using System;
namespace Test {
static void Main(string[] args) {
// How to get my menu??? like showmenu();

}
}

using System;
namespace Test
{
/// <summary>
/// Summary description for showMenu.
/// </summary>
public showmenu() {
// some code
}
}


You can't do that in C# -- namespaces are for holding classes only.

You'd have to do something like this instead:

namespace Test
{

public class Menu
{
public static Show()
{
}
}

}

Note that the name has changed from "ShowMenu" to "Show", since "Show"
is implemented in the "Menu" class.

Then call this static method with: Menu.Show();

<snip>

Nov 15 '05 #5
"Arjen" <bo*****@hotmail.com> wrote:
C# doesn't knows functions, procedures and contructors?

Thanks!


In Delphi (formerly known as Object Pascal), a function is a routine
that explicitly returns a value, and a procedure is a routine which
doesn't. I'm presuming this is what you mean here.

In C#, you can only define *methods*, which are functions or routines
of a class.

You can define either instance methods or static methods. Instance
methods are called upon an instance of a class, whereas static methods
aren't.

Static methods are, in a sense, functions/procedures which need to be
called with the *class name* as a prefix.

Here:

namespace MyNamespace
{

public class MyClass
{
public static void Procedure()
{
}

public static int Function()
{
}
}

You can call either of these like:

MyClass.Procedure();
MyClass.Function();

Note that you are *not* creating an instance of MyClass here, you are
simply calling its static methods.

As for constructors, C# has them, and their meaning is similar to
those of other languages:

public class MyClass
{
void MyClass()
{
Console.WriteLine("I am a constructor of MyClass!");
}
}

This is similar to the following Delphi code:

interface

type TMyClass = class
public
constructor Create;
end;

implementation

constructor TMyClass.Create;
begin
WriteLn("I am a constructor of TMyClass!");
end;
Nov 15 '05 #6
> In Delphi (formerly known as Object Pascal), a function is a routine
that explicitly returns a value, and a procedure is a routine which
doesn't. I'm presuming this is what you mean here. Yes. ;-)

Thanks for your answer!
Arjen

"C# Learner" <cs****@learner.here> schreef in bericht
news:2r********************************@4ax.com... "Arjen" <bo*****@hotmail.com> wrote:
C# doesn't knows functions, procedures and contructors?

Thanks!


In Delphi (formerly known as Object Pascal), a function is a routine
that explicitly returns a value, and a procedure is a routine which
doesn't. I'm presuming this is what you mean here.

In C#, you can only define *methods*, which are functions or routines
of a class.

You can define either instance methods or static methods. Instance
methods are called upon an instance of a class, whereas static methods
aren't.

Static methods are, in a sense, functions/procedures which need to be
called with the *class name* as a prefix.

Here:

namespace MyNamespace
{

public class MyClass
{
public static void Procedure()
{
}

public static int Function()
{
}
}

You can call either of these like:

MyClass.Procedure();
MyClass.Function();

Note that you are *not* creating an instance of MyClass here, you are
simply calling its static methods.

As for constructors, C# has them, and their meaning is similar to
those of other languages:

public class MyClass
{
void MyClass()
{
Console.WriteLine("I am a constructor of MyClass!");
}
}

This is similar to the following Delphi code:

interface

type TMyClass = class
public
constructor Create;
end;

implementation

constructor TMyClass.Create;
begin
WriteLn("I am a constructor of TMyClass!");
end;

Nov 15 '05 #7

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

Similar topics

2
by: zapazap | last post by:
Dear Snake Charming Gurus, (Was: http://mail.python.org/pipermail/python-list/2004-January/204454.html) First, a thank you to Tim Golden, Thomas Heller, and Mark Hammond for your earlier help...
6
by: Roberto Dias | last post by:
Could anyone give me some tips about how to start a menu-based console application using C++ function oriented programming techniques? I'm a FORTRAN-based electrical engineer and a newbie on C++...
2
by: pantagruel | last post by:
I have an old web application I did where browsers with dynamic capabilities received a drop down menu on the top of the page and a fold out on the left hand side of the page and non-dynamic...
4
by: William McIlroy | last post by:
Array Bounds Exception inside system.xml.dll. Test data is a dozen GB (available for the asking on CD). Source code follows. Call into system.xml.dll happens at the while statement.. using...
0
by: Mike Schilling | last post by:
Consider these two statements: 1. Writing to System.Console.Out in a program running inside IIS has no effect. This comes from observation. I have some code which writes an exception stack...
2
by: Stuart Norris | last post by:
Dear Group, I am new to c# and windows form designer - coming from a Motif background. I am attempting to develop an application for a touch screen and I need to have a menu system with a...
5
by: Lambuz | last post by:
First of all, is it possible usign .NET remoting feature inside a .NET applet loaded into a tag object inside an HTML page ? <OBJECT id="myID" height="150" width="300"...
3
by: Poggs | last post by:
Hi everyone, I used the pattern for Shell Extensions for Context menu from Dino Esposito's article. However I implemented it in more than one application and it seems that those two right click...
1
by: Hendrik van Rooyen | last post by:
I am writing a small application with a simple ascii based menu. The menu is used to test individual functions, and to change some timings. Otherwise the application just runs automatically,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

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.