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

  • Home
  • SEARCH
  • 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 8753645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:28:01+00:00 2026-06-13T13:28:01+00:00

Maybe my question weird… I wonderd if it possible to use reflection on a

  • 0

Maybe my question weird… I wonderd if it possible to use reflection on a phrase.

I tried to make comparison with reflection in C#. Until now I passed the name of the property as string and the value as object, like that: Cmp("foo", "abc").
In this way I have to check if foo is existing property in the class, and check if the value type match the property type (in the example above foo is string property, and the value is string). This way works fine!

I just wonder if it possible to send phrase as parameter and analize it with reflection or something simmilar.
I mean, as in the example above instead of calling the function like that Cmp("foo", "abc") just call the function like this Cmp(A.foo == "abc") (A is class that have foo propery), then analize that the property is foo and the value is "abc".

I know its sounds weird, and its not necessary for me. Its just for the idea.
Is it possible?

EDIT
If I was not clear, I have wrote the Cmp(string, string) method, and it works fine!
I just want to know if there is way to write the Cmp method like this: Cmp(A.foo == "abc"). That the parameter is a phrase.

EDIT 2
For example you can do something like it in C. You can create macro like that:

#define Cmp(phrase) printf(##phrase)

Then if you call it like Cmp(A.foo == "abc") the output will be:

A.foo == “abc”

Like pass the whole phrase as parameter and analize it. I know that macro is pre-compile thing, I just want to know if there is something like that in C#

  • 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-06-13T13:28:02+00:00Added an answer on June 13, 2026 at 1:28 pm

    You can use expression trees to describe an expression like bar.Foo == "abc". Here is a simple example that assumes the you have a class named Bar that has a property named Foo:

    String FormatExpression<T>(Expression<Func<T, Boolean>> expression) {
      if (expression == null)
        throw new ArgumentNullException("expression");
      var body = expression.Body as BinaryExpression;
      if (body == null)
        throw new ArgumentException(
          "Expression body is not a binary expression.", "expression");
      return body.ToString();
    }
    

    Calling

    FormatExpression((Bar bar) => bar.Foo == "abc")
    

    will return the string

    (bar.Foo == "abc")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe my question it's a little weird, but I'm trying to build a not-so-simple
Maybe my question might seem a bit weird, but I have an activity in
Maybe this is a stupid question but javascript is a weird thing. I secured
Maybe the question sound not good or too simple. But not for me in
Maybe the question is familiar but I need an explanation in this case. Let's
Maybe this question has been asked many times before, but I never found a
Maybe dumb question: I'm trying to realize a little server in Java with com.sun.net.httpserver
Maybe the question sounds silly. Who is the provider,in the above statement? Is it
This question maybe a better fit on The Business of Software forum but despite
I had a (maybe simple) question about the CAS protocol . From what I

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.