Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6532997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:04:18+00:00 2026-05-25T10:04:18+00:00

Is it possible to use extension methods to extend an indexer? I want to

  • 0

Is it possible to use extension methods to extend an indexer? I want to be able to get cell’s value from DataGridViewCell of given DataGridViewRow using header text like this:

object o = row["HeaderText"]; 

I have this code

public static class Ext
{
    public static object Cells(this DataGridViewRow r, string header)
    {
        foreach (DataGridViewCell c in r.Cells)
        {
            if (c.OwningColumn.HeaderText == header)
            {
                return c.Value;
            }
        }
        return null;
    }
}

and I want similar indexer. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:04:19+00:00Added an answer on May 25, 2026 at 10:04 am

    Indexers are actually properties, and extension properties do not exist in C#. So this can’t be done the way you want.

    See this blog post for some background on the subject, and an explanation as to why that feature was considered, but ultimately omitted from C# 3.0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: IEnumerable Extension Methods on an Enum How can I use Generics to
Possible Duplicate: What are Extension Methods? Hi, After googlin got to know a bit
Possible Duplicate: Why doesn’t VS 2008 display extension methods in Intellisense for String class
I have recently started to make useful use of C# extension methods. The SO
Is it possible to return a generic type using extension methods ? For example,
Possible Duplicate: Why is the 'this' keyword required to call an extension method from
I have created a few WebRequest extension methods that support cancelling. Is it possible
I'm attempting to use extension methods to add an operater overload to the C#
I have a few 'helper' style extension methods I use quite regularly now (they
I want to replace extension methods included in the .NET or ASP MVC framework

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.