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. LINQ
  4. Extended Methods

Extended Methods

Scheduled Pinned Locked Moved LINQ
csharpquestion
2 Posts 2 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.
  • M Offline
    M Offline
    Member 3981366
    wrote on last edited by
    #1

    Is extension method = static method returning strongly typed variables or collections? i read one entry about it saying -- "this" keyword as a static method param tells The compiler that this particular Extension Method should be added to objects of type default .net class. SO do we need to add "this" keyword for creating extended method or every static method in static class can be called extension method?

    A 1 Reply Last reply
    0
    • M Member 3981366

      Is extension method = static method returning strongly typed variables or collections? i read one entry about it saying -- "this" keyword as a static method param tells The compiler that this particular Extension Method should be added to objects of type default .net class. SO do we need to add "this" keyword for creating extended method or every static method in static class can be called extension method?

      A Offline
      A Offline
      ABitSmart
      wrote on last edited by
      #2

      From here[^], "Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type."

      Member 3981366 wrote:

      returning strongly typed variables or collections

      Sorry, I don't understand what you mean.

      Member 3981366 wrote:

      do we need to add "this" keyword for creating extended method

      Yes, if you want it to be used as an Extension method i.e. the compiler automatically glueing the code for linking the static extension method to the instance object

      Member 3981366 wrote:

      every static method in static class can be called extension method

      No, since you cannnot use static methods with instance object. There lies the major inclination of extension methods.

      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