Note that there are some explanatory texts on larger screens.

plurals
  1. POAdvice on Method overloads
    primarykey
    data
    text
    <p>Please see following methods.</p> <pre><code> public static ProductsCollection GetDummyData(int? customerId, int? supplierId) { try { if (customerId != null &amp;&amp; customerId &gt; 0) { Filter.Add(Customres.CustomerId == customerId); } if (supplierId != null &amp;&amp; supplierId &gt; 0) { Filter.Add(Suppliers.SupplierId == supplierId); } ProductsCollection products = new ProductsCollection(); products.FetchData(Filter); return products; } catch { throw; } } public static ProductsCollection GetDummyData(int? customerId) { return ProductsCollection GetDummyData(customerId, (int?)null); } public static ProductsCollection GetDummyData() { return ProductsCollection GetDummyData((int?)null); } </code></pre> <p>1- Please advice how can I make overloads for both CustomerId and SupplierId because only one overload can be created with GetDummyData(int? ). Should I add another argument to mention that first argument is CustomerId or SupplierId for example GetDummyData(int?, string). OR should I use enum as 2nd argument and mention that first argument is CustoemId or SupplierId.</p> <p>2- Is this condition is correct or just checking > 0 is sufficient -> if (customerId != null &amp;&amp; customerId > 0)</p> <p>3- Using Try/catch like this is correct?</p> <p>4- Passing (int?)null is correct or any other better approach.</p> <p><strong>Edit:</strong></p> <p>I have found some other posts like this and because I have no knowledge of Generics that is why I am facing this problem. Am I right? Following is the post.</p> <p><strong><a href="https://stackoverflow.com/questions/422625/overloaded-method-calling-overloaded-method">Overloaded method calling overloaded method</a></strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload