C# classes

In a MS C# application, how would I do the following?  I'd like to call another function without using the class names.

Main.cs

using System;
using System.Collections.Generic;
using System.Text;


namespace IRule
{
    class Program
    {
        static void Main(string[] args)
        {
            runme();            
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;

namespace CKann
{
    public abstract class Foo
    {
           public static void runme()
           {
                   string blah;
           }
    }
}
LVL 11
thunderchickenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gautham JanardhanCommented:
u will have to call it as
Foo.runme()
i dont think u can skip the class name
0
Babycorn-StarfishCommented:
hi,

if runme() was a static function within Program you could do that otherwise you need to fully qualify it with a class/instance name.
0
thunderchickenAuthor Commented:
Yeah, that's what I'm doing now, I don't want to do that.
0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

jasonclarkeCommented:
Can you post some code that demonstrates what you are doing (i.e. what calls you are making) and what you would like to do?
0
Babycorn-StarfishCommented:
i'm just curious at to why you wouldn't want to do that. Are you just after a shorthand for calling a method?
0
thunderchickenAuthor Commented:
I'm copying over a bunch of C code and I don't want to have to copy/paste the class name for each call.  There's a ton of global variables / enums / etc that it's using and it's a way to make it cleaner.
0
Babycorn-StarfishCommented:
if each method etc, was guaranteed to be uniquely named you could past it in then run through find replace for each method/enum and append the qualifying class/instance name, still pretty unwieldy process though.

Good luck!
0
thunderchickenAuthor Commented:
Yeah, that's what I'm doing now.  I know you can do this stuff in VB.NET, wasn't sure about C#.  Thanks
0
jaylorenzoCommented:
You have to inherit from Foo, as you have defined it as an abstract class.
That's the only way you can call the method.

Use it like:

public class Bar:Foo
{
  #region Foo Members
     public static void runme()
     {
          base.runme();
     }
  #endregion
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.