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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:55:38+00:00 2026-05-24T01:55:38+00:00

Is it possible to loop through a function arguments to check if any of

  • 0

Is it possible to loop through a function arguments to check if any of them is null(or check them by another custom function)?
something like this:

public void test (string arg1, string arg2, object arg3, DataTable arg4)
{
    foreach (var item in argus)
        {
            if( item == null)
             {
                throw;
             }
        }
   // do the rest...
}

what is the correct keyword for “argus”? I know that this is possible by some more if statement but looking for a faster way…

  • 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-24T01:55:39+00:00Added an answer on May 24, 2026 at 1:55 am

    I suppose you don’t want to change to params each method in your project(s). You can use PostSharp, but there are other methods, depends on your framework.

    using System;
    using System.Data;
    using System.Reflection;
    using PostSharp.Aspects;
    
    namespace TestAOP
    {
        class Program
        {
            static void Main(string[] args)
            {
                SomeClass someInstance = new SomeClass();
                someInstance.test(null, null, null, null);
            }
        }
    
    
        public class SomeClass
        {
            [CheckForNulls]
            public void test(string arg1, string arg2, object arg3, DataTable arg4)
            {           
                // do the rest...
            }
        }
        [Serializable]
        public class CheckForNullsAttribute : OnMethodBoundaryAspect
        {
            public override void OnEntry(MethodExecutionArgs args)
            {
                ParameterInfo[] parameters = args.Method.GetParameters();            
                for (int i = 0; i < args.Arguments.Count; i++)
                {
                    if (args.Arguments[i] == null)
                        throw new ArgumentNullException(parameters[i].Name);
                }
            }
        }
    }
    

    http://www.sharpcrafters.com/ to get PostSharp, also you can find doc there.

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

Sidebar

Related Questions

I have a for loop in pl/sql function something like: FOR i IN min..max
Is it possible to loop through a query so that if (for example) 500,000
Is it possible to use any loop optimization technique here to reduce the execution
I have a string with possible command line arguments (using an Read-Eval-Print-Loop program) and
I'd like some help with the following jQuery code if possible... $(document).ready(function() { $('table.sortable').each(function()
I'm trying to create an export Excel/CSV function that will iterate through a custom
I would like to be able to loop through a list which is a
This might be hard to explain, but I need a way to loop through
Possible Duplicate: How do i Loop through the hidden field items and put in
Possible Duplicate: How does foreach work when looping through function results? Title has the

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.