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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:13:50+00:00 2026-06-10T12:13:50+00:00

while writing the question subject I came across some other allmost related post …leading

  • 0

while writing the question subject I came across
some other allmost related post …leading to MSDN
http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo.aspx

but i couldn’t manage to extract the bit of code i needed

i just learnd how to get method name with a helper method based on st and sf as following :

    public void setLogView(View ViewMode)
    {
        AAdToAppLog();

        Lview_AH_AutomationLog.Sorting = SortOrder.Ascending;
        ColumnHeader ColHeadRowNo = new ColumnHeader();
        ColumnHeader ColHeadFunction = new ColumnHeader();
        ColumnHeader ColHeadContent = new ColumnHeader();
        ColumnHeader ColHeadTime = new ColumnHeader();

        Lview_AH_AutomationLog.View = ViewMode;
        Lview_AH_AutomationLog.Columns.Add(ColHeadRowNo);
        Lview_AH_AutomationLog.Columns.Add(ColHeadFunction);
        Lview_AH_AutomationLog.Columns.Add(ColHeadContent);
        Lview_AH_AutomationLog.Columns.Add(ColHeadTime);
        ColHeadRowNo.Text = "#";
        ColHeadFunction.Text = "Function Name";
        ColHeadContent.Text = "Content";
        ColHeadTime.Text = "Time";
        ColHeadRowNo.Width = 45;
        ColHeadFunction.Width = 150;
        ColHeadContent.Width = 150;
        ColHeadTime.Width = 100;
    }



    public void AAdToAppLog(string FunctionOutPut = "N/A")
    {
        string t = DateTime.Now.ToString("mm:ss.ff");
        string h = DateTime.Now.ToString("HH");
        ListViewItem FirstCell= new ListViewItem();
        FirstCell.Text =h+":" +pre0Tosingle_9(LogCounter.ToString());//Another helper puts 0 infront <=9 digits
        Lview_AH_AutomationLog.Items.Insert(0, FirstCell);
        StackTrace st = new StackTrace(); 
        StackFrame sf = st.GetFrame(1);
        string FunctionName = sf.GetMethod().ToString().Replace("Void", "").Replace("System.Windows.Forms.", ""); 
        FirstCell.SubItems.Add(FunctionName);
        FirstCell.SubItems.Add(FunctionOutPut);
        FirstCell.SubItems.Add(t);

        LogCounter++;

    }

so in every method i want i just put the

AddToAppLog()

that method contains my call to AddToAppLog() and then reports(Via ListView) the name of method and i just added the time of the call.

there’s two things i would like to address in this post , about my implementation of that helper metod :
the “FunctionName” i recive from sf.GetMethod is nice that it throws the type of the Parameter of a given Method i liked the idea , only that it is containing parameter.type’s Father + Grandfather + Great-Grandfather, but i would like only the bottom Type :

System.Windows.Forms.View

this is one of the shortest (: and i tried to get to View by it self via playing with .Replace()
so is there anothere way to strip it down or actually another method in same family that extract it the way i mentiond above or i could use a list containing every possible most-used types and do a foreach with stringReplace?

and more importently , how do i get the Method(parameterName) as well ?

thanks alot in advance !!

can someone Show An easy to comprehend , Simple syntax Example
of getting parameters name ?

  • 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-10T12:13:52+00:00Added an answer on June 10, 2026 at 12:13 pm

    The crux of this is the line that involves sf.GetMethod(); if you instead store that:

    var method = sf.GetMethod();
    string name = method.Name;
    var parameters = method.GetParameters();
    

    you have access to the full signature, and note that the .Name is just the simple name – not the full declaring type-name, etc. You can of course access method.DeclaringType.Name if you want more context. Note that you can only get the declaration of the parameters; you can’t get their values via any normal mechanism.

    However!!! I will also observe that all this has a performance cost associated with reflection and stack-walking. If you have the C# 5 compiler, you may prefer:

    public void AAdToAppLog([CallerMemberName] string callerName = "")
    { ... }
    

    which means that the compiler will supply the name of the caller voluntarily (as a constant geneated in the IL) – no need to either supply it, or go walking the stack to figure it out. You cannot, however, get the parameters like this.

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

Sidebar

Related Questions

While writing some code i came across this issue: #include <iostream> class random {
While writing a simple server-client application, this question came in my mind. When someone
While doing some Java homework I answered a question by writing an instance method,
Somewhat of an academic question, but I ran into this while writing some unit
I figured out what the problem was while writing this question. I post it
While writing functional tests for a controller, I came across a scenario where I
Best practices question. While I was writing some event handlers, I ran into an
While writing an encryption method in JavaScript, I came to wondering what character encoding
While writing some C code, I decided to compile it to assembly and read
While writing a login system for a web project Im working on I came

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.