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 5977839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:25:42+00:00 2026-05-22T21:25:42+00:00

I’ve been at this for at least 3 hours now – 1.5 – 2

  • 0

I’ve been at this for at least 3 hours now – 1.5 – 2 of which has been spent just learning regex in order to do this. I am still nowhere near comprehending it, but that’s not quite the priority: I’d rather get this algorithm flushed out first.

SO..

Here, I have a nice little method which accepts a string which is basically supposed to contain a phrase that determines what kind of bindingflag to return. The string is evaluated by the regexpression. If this expression comes out to true, it goes onward to move through an array which lists the proper BindingFlags settings to set. I have most of this figured out – the main problem is A) simplicity, and B) the last two bits: ensuring that a BindingFlag will be returned (Which I believe I have done, but I still get a logic error from that, so obviously I haven’t), and comparing the string with the actual BindingFlag array to determine which flag to select and return.

Kind of complicated for my level. Here’s the code:

private static BindingFlags CheckPropBinding(string bindFlagSpec) 
        {
            BindingFlags binderFlag; //--will be returned.

            string bindLower = bindFlagSpec.ToLower(); //--lowers string parameter.

            Match matchBinder; //--our matcher :).

            string regex = "regex dummy"; /*--this is a dummy which will be replaced when I've found the appropriate regex to use. */

            matchBinder = Regex.Match(bindLower, regex); 

            if (matchBinder.Success) //--if success, will go on...
            {
                for(int bindIndex = 0; bindIndex < bindings.Length; bindIndex++) /*--compares string with bindingFlag array */
                {
                    if (bindLower.Contains(bindings[bindIndex].ToString()))
                    {
                        binderFlag = bindings[bindIndex];

                        break;
                    }
                    else 
                    {
                        if (bindIndex == bindings.Length && !bindLower.Contains(bindings[bindings.Length].ToString())) 
                        {
                             binderFlag = BindingFlags.NonPublic; /*--this is just a

last resort check, assigning a default flag if for some reason one can’t be selected.*/
break;
}

                        continue;
                    }

                 }
            }


            return binderFlag; //--returned :).
       }

I should probably also mention the binding flags array field:`

public class PropertyManagener
    {
        private static BindingFlags[] bindings = {BindingFlags.NonPublic, BindingFlags.Public, 
                                                     BindingFlags.Static, BindingFlags.Instance};
  • 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-22T21:25:42+00:00Added an answer on May 22, 2026 at 9:25 pm

    The error is because you’re not guaranteed to be initializing binderFlag before returning it. Why not do something like this instead? This sets the binderFlag to your default return value up front, so that if your algorithm can’t determine what to use, it returns NonPublic.

    This at least will resolve the compiler error! I can’t speak to the actual correctness of the algorithm you’ve implemented, unfortunately.

        private static BindingFlags CheckPropBinding(string bindFlagSpec)         
        {
            BindingFlags binderFlag = BindingFlags.NonPublic;
            string bindLower = bindFlagSpec.ToLower(); //--lowers string parameter.            
            Match matchBinder; //--our matcher :).            
            string regex = "regex dummy"; /*--this is a dummy which will be replaced when I've found the appropriate regex to use. */            
            matchBinder = Regex.Match(bindLower, regex);
            if (matchBinder.Success) //--if success, will go on...            
            {
                foreach (BindingFlags t in bindings)
                {
                    if (bindLower.Contains(t.ToString()))
                    {
                        binderFlag = t;
                        break;
                    }
                }
            }
            return binderFlag; //--returned :).       
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.