Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Calling a method without object or its class name..

Calling a method without object or its class name..

Scheduled Pinned Locked Moved C#
toolshelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nasambur
    wrote on last edited by
    #1

    hi.. i'm writing a utility package for my tool.. i want a method to be used globally that can be called with out object or its class name.. is it possible. plz help me.. regards, nas

    M R 2 Replies Last reply
    0
    • N nasambur

      hi.. i'm writing a utility package for my tool.. i want a method to be used globally that can be called with out object or its class name.. is it possible. plz help me.. regards, nas

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, Have you tried a static method? All the best, Martin

      J 1 Reply Last reply
      0
      • M Martin 0

        Hello, Have you tried a static method? All the best, Martin

        J Offline
        J Offline
        joon vh
        wrote on last edited by
        #3

        A public static class with public static methods is probably as close as you can get. Then you can just use Class.DoMethod() from anywhere where the class is available (same project or it's in a reference, don't forget using directive) namespace Globality { public static class GlobalClass { public static void MyMethod() { } } } and then somewhere else using Globality GlobalClass.MyMethod();


        Visual Studio can't evaluate this, can you? public object moo { __get { return moo; } __set { moo = value; } }

        1 Reply Last reply
        0
        • N nasambur

          hi.. i'm writing a utility package for my tool.. i want a method to be used globally that can be called with out object or its class name.. is it possible. plz help me.. regards, nas

          R Offline
          R Offline
          Russell Jones
          wrote on last edited by
          #4

          you could have a public static delegate declared in your app and then assign it when the object containing the method you want to call is instantiated. Russell

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups