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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:12:31+00:00 2026-05-12T23:12:31+00:00

Okay, I will cut and paste from .NET reflector to demonstrate what I’m trying

  • 0

Okay, I will cut and paste from .NET reflector to demonstrate what I’m trying to do:

public override void UpdateUser(MembershipUser user)
{
    //A bunch of irrelevant code...

    SecUtility.CheckParameter(ref user.UserName, true, true, true, 0x100, "UserName");

    //More irrelevant code...
}

This line of code comes right out of System.Web.Security.SqlMembershipProvider.UpdateUser (System.Web.dll v2.0.50727) in the .NET Framework.

The SecUtility.CheckParameter requires a reference value as the first parameter, to which they’re passing a property of the user passed in as the argument.

The definition of the CheckParameter code is:

internal static void CheckParameter(ref string param, bool checkForNull, bool checkIfEmpty, bool checkForCommas, int maxSize, string paramName)
{
    //Code omitted for brevity
}

Everything it’s doing makes sense – on paper… so I knock up a quick little prototype for somewhere I’d like to use something similar:

public class DummyClass
{
    public string ClassName{ get; set; }
}

public class Program
{
    private static DoSomething(ref string value)
    {
        //Do something with the value passed in
    }

    public static Main(string[] args)
    {
        DummyClass x = new DummyClass() { ClassName = "Hello World" };

        DoSomething(ref x.ClassName); //This line has a red squiggly underline 
                                      //under x.ClassName indicating the 
                                      //error provided below.
    }
}

This code won’t compile – the error shows as:

"A property or indexer may not be passed as an out or ref parameter"

Fair enough… but why won’t my code allow me to do something that appears to be in the .NET Framework code base? Is this an error with the way .NET Reflector is interpreting the DLL or is this an error with the way I’m interpreting their code?

  • 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-12T23:12:31+00:00Added an answer on May 12, 2026 at 11:12 pm

    I think it is some bad interpretation from Reflector. Actually if you write your code like this:

    static void Main(string[] args)
    {
        DummyClass x = new DummyClass();
        string username = x.ClassName;
        DoSomething(ref username);
    }
    

    and compile it in Release mode you will see this in Reflector:

    static void Main(string[] args)
    {
        DummyClass x = new DummyClass();
        DoSomething(ref x.ClassName);
    }
    

    Remember that the C# compiler is not producing C# code but IL so what you see in Reflector is not always the reality. So to clearly understand what is going on under the hood you may look at the real code produced by the compiler:

    L_000f: callvirt instance string System.Web.Security.MembershipUser::get_UserName()
    L_0014: stloc.0 
    L_0015: ldloca.s str
    L_0017: ldc.i4.1 
    L_0018: ldc.i4.1 
    L_0019: ldc.i4.1 
    L_001a: ldc.i4 0x100
    L_001f: ldstr "UserName"
    L_0024: call void System.Web.Util.SecUtility::CheckParameter(string&, bool, bool, bool, int32, string)
    

    It is clear that a local variable is used.

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

Sidebar

Related Questions

okay so I want to make a public function that will return YES if
Okay, I will just leave my code here . As you can see from
Okay, so I'm trying to make a method that will return the level order
Okay, I will shortly be starting down the path of windows mobile development. I
Okay: I'm fairly new to C++ and static languages on a whole. Coming from
Okay, so this will probably be closed or whatever, I don't care. I have
Okay I will first admit I don't know the proper terminology for all this
The following code is undefined behavior in C++ (although it will work okay on
Okay basically I am creating a stored procedure that will return data for our
Okay, I get that performing the following will create an array of my string

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.