.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Abstract method with variable number of paramters

Posted By:      Posted Date: September 13, 2010    Points: 0   Category :ASP.Net
Hi All,Say I have an abstrac method and I want all my Child classes that inherite this method to have different number of input parameters.e.gabtract class Anything { abstract TestFunc() } class Something1 : Anything { TestFunc(string aa) { ... } } class Something2 : Anything { TestFunc(string bb, int cc) { ... } } How would I go about declaring this in my abstract class?

View Complete Post

More Related Resource Links

CLR Stored procedures : variable number of input paramters?


Hi there, I've just started looking into CLR stored procedures.

I'd like to create a stored procedure that takes in a variable number of parameters in the same way that sp_executesql does. 

I've tried creating the CLR proc as follows;

using System;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server; 

public class StoredProcedures 
  public static void PriceSum(params SqlString[] parms)


but this results in the following error;

Error	1	Column, parameter, or variable #1: Cannot find data type SqlString[].	StringFactory

so I'm guessing it can't be done. 

Is there a way to mimic sp_executesql ?

Embeb a variable number of videos


I need to provide some alternate content for my non-Flash users.

I have a directory of video files that is scanned using the DirectoryInfo() function, and I want to use the results to embed all files ending in ".mov" in QuickTime players on a web form.

How would you approach this? Right now I am using the count on the array of videos to determine how many times to repeat the embed code.  But this seems inelegant.

Is there a way to have a single QuickTime player.ascx control that gets duplicated according to the number of videos available for display?

Different number of data in Report after using Render method.

Hello All, I have CRM4 report that i execute from outside the CRM system, using the ReportExecutionService2005.asmx web service, i get the report exported directly by calling the Render method of the webservice, but when i compare the data of the Report outside the CRM is less then the data in the report executed from within CRM system. I have tested the same report with same user in CRM and outside CRM but data is different. can someone guide me what is going wrong in the Render method.BharatKumar Bambhaniya Software Developer.

Need help with "ORA-01036: illegal variable name/number" error on SQLDataSource


I keep gettin this error on the Data Source. Any ideas on how to fix this?


<asp:SqlDataSource ID="sdsLastName" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
	<asp:controlparameter ControlID="ddType" DefaultValue="LAST_NAME"  PropertyName="SelectedValue"  ConvertEmptyStringToNull="true" />


Variable number of colomns in ssrs report



I have a stored procedure which is built on PIVOT fuction. I am using the stored procedure to generate a report.

some time the stored procedure will generate the variable no of colomns, in ssrs dataet is updating with variable no of colomns, at that time report is not supporting.

i am using table control in SSRS. some one suggested me matrix control, but i need to change my stored procedure to work with matirx control.

i dont want to change the stored procedure.

can any one suggest me how to resolve this in SSRS.



Using Excel Source with variable number of columns



I want periodically to insert data from an excel file into a relational table using a SSIS package. However, each time the number of columns in excel may vary. For example, the 1st time the excel file may have 100 rows the second 105 rows etc.

Can this be done in SSIS and if yes what is the solution?


Thanks in advance,


how do you get object array number in a method?


Lets say you have four array objects.

test[1] = new test();

test[2] = new test();

test[3] = new test();

test[4] = new test();

then you have your class:

public class test()


   public int i; //initialize some fields

   public int getnumber()


  // what is the array number of the this object? 1, 2, 3, or 4???



so basically, if an object is called: test[1].getnumber   how can this method internally determine what object array number it is currently in?  (without passing an integer from the page)

  it can be either 1, 2,3, or 4.

What is the point of defining a method abstract?



I am reading a C# book and it says that in order to force classes to override a method (say Draw() ) you define it as abstract.

So far so good. However what's the point of forcing each class to override a method implementation, and not just create a new method for each class?

An example is the one with the Shapes class and the Draw() method. Each shape class must override the public abstract void Draw() method in order to draw itself.

Why not ommit that, and define a Draw method inside each shape? (i.e. square class, triangle class etc).


DATEADD number as variable


I'm trying to use a variable in the DATEADD(dd, @dt1, GETDATE()).  This always throws an error, it can't convert the variable properly, but even when I do something like DATEADD(dd, CONVERT(int, @dt1), GETDATE()), still error.

Any help is appreciated!

how to call a session variable in Web service Method in Default.cs file



I have used a web service method in my Application. And as per the requirement using one user. I am searching for a list of schools to a particular area. When one person logged with the credentials , search criteria works fine when another person logs in there the problem like session variable is getting overriden . This is a issue which I am facing and as per its very urgent to solve the problem. Please help me and solve the Issue.

Please repond Immediately, as I am unable to sleep at nights.

I am also sending the code of a sample example 


using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
    //public string str;
   // SharedPersonalizationStateInfo string str;
    static string str1;
    static string strName;
    static  string strSqlquery;
    protected void Page_Load(object sender, EventArgs e)

        if (!IsPostBack)
            strName = Session["ID"].ToString();
            str1 = Session["FriendID"].ToString();

Variable number of columns in sql for xml


I have a schema where one of my column in xml can appear 0 or 1 time.

That is fairly easy when it is a subquery. But I don't know how to do it in a main query.

Here is an example of what I want:


Abstract Factory Design in C# , Vb.NET

Provide an interface for creating families of related or dependent objects without specifying their concrete classes

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.

Abstract Factory Design Pattern (Sample in C# and VB .NET)

An abstract factory provides an interface for creating families of related objects without specifying their concrete classes. Sometimes one wants to construct an instance of one of a suite of classes, deciding between the classes at the time of instantiation. In order to avoid duplicating the decision making everywhere an instance is created, we need a mechanism for creating instances of related classes without necessarily knowing which will be instantiated.

Abstract Factory Pattern-Creational Patterns

The Factory pattern allowed us to decouple our client from an object which it uses. The Abstract Factory pattern extends this idea to manage separate families of objects.

A runtime selection, or configuration option, in our client could decide which family of objects is to be used. The Abstract Factory pattern allows us to write generic code to instantiate and use the family objects regardless of which family is chosen at runtime. The pattern also helps us enforce a rule where objects from just the chosen family are used uniformly by the client.

Local variable scoping in C#

In my previous post, Compiler-generated scopes for local variable declarations, I briefly touched on the issue of multiple meanings applied to the same name. In this post, I'll aim to flush out the compiler's rules with regards to binding names in their local scopes.

Compiler-generated scopes for local variable declarations

I was tasked with understanding and fixing a bug on error reporting with foreach iteration variables the other day, and it got me thinking about local variable scoping rules in C# in general. First, the bug.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend