Understand Polymorphism When Using Generics In C#?
Aug 25, 2010
I am having a problem understanding how polymorphism works when using generics. As an example, I have defined the following program:
public interface IMyInterface
{
void MyMethod();
}.....
So, at least I haven't completely misunderstood that. I am unsure exactly how I am to write a method that accepts a generic collection of classes that conform to the same interface.
I have a plan to completely hack around this problem if need be, but I would really prefer to do it properly.
View 3 Replies
Similar Messages:
Feb 10, 2010
[Code]....
polymorphism and databinding to a datagrid?
View 2 Replies
Jun 17, 2010
Can you give me an scenario example how you have used polymorphism in your project. With new and override keyword.
give me an example from a finance domain/ecommerce domain. I am looking from a UML Model Perspective.
View 1 Replies
Jun 17, 2010
Can you give me an scenario example how you have used polymorphism in your project. With new and override keyword.
View 2 Replies
May 11, 2010
I have a class, let's say class Sample. Sample has unknown properties but inherits an interface ISample. Said interface includes one method which I'm trying to create. This interface has a method called getPropertyValue(object o, string PropertyName).
It returns the value of the o.PropertyName using generics (unless you have a better suggestion). How do I write it? In other words, I want to be able to pass the name (as a string) of a property and return its value. Samples in C# preferrable but VB ok and any comments or suggestions are welcome.
View 2 Replies
Apr 29, 2010
i am trying to implement a generic method which allows to output csv file
public static void WriteToCsv<T>(List<T> list) where T : new()
{
const string attachment = "attachment; filename=PersonList.csv";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
[Code]....
but I am not able to get the value of the object's property
View 2 Replies
Feb 12, 2010
I'm working with some XML representations of data instances. I'm deserializing the objects using .NET serialization but something in my soul is disturbed by having to write classes to represent the XML... Below is what I'd LOVE to do but I don't know if the syntax or if it is even possible:Consider the following:
dim xmlObject = SomeXMLFunction() 'where some function returns an object/string representation of xml...
xmlObject.SomePropertyDefinedInTheXML = SomeFunction()
View 4 Replies
Jul 12, 2010
I had asked with one question in the interview regarding generics
How can we restricts the one generic method to take only the value types.It should not be able to take reference types.
View 2 Replies
Jul 16, 2010
I know that in ASP.NET (talking about 2.0 here primarily) one can set a property on an object that takes a collection of things (an enumerable type I'm guessing is the trigger) and then reference it declaritivly. For example:
<ObjectDataSource properties="blahblahblah">
<SelectParameters>
<asp:Parameter />
</SelectParameters>
</ObjectDataSource>
It is the <asp:Parameter /> part which is the root of my question. Say I wanted a simpler collection on a type. Say a List<String> or if generics are out, an IntegerCollection or StringCollection. How would I use that declaratively? Is <string value=''> allowed, or can I put raw values into it like <StringCollection>string, string, string</StringCollection> or what?
EDIT:
I feel like I was not clear enough in my question. I understand that ObjectDataSource implements its SelectParameters property as a ParametersCollection, and that one can use that property declaratively (in an ASPX page) to set up Parameter types within that collection. What I'm wondering is if I made something like StringCollection as a property on another control, is there a syntax (in ASPX) for adding strings to that collection? Or would I have to define a wrapping class like how DropDownList takes ListItems to fill its collection?
View 2 Replies
Oct 18, 2010
For reasons I won't go into I need to use CLR generics syntax in an ASP.NET MVC view.
I.E. NOT this:
System.Web.Mvc.ViewUserControl<someobject>
but this:
System.Web.Mvc.ViewUserControl`1[[someobject]]
When I run the application I get
Parser Error: could not load type `System.Web.Mvc.ViewUserControl`1[[someobject]]
View 2 Replies
Mar 4, 2010
I tried so much working with this to get distinct Words and their count. I'm using ASP.NET 2.0. And i also googled so much.
1)Ex(String): The DOTNET is Very Cool! The Best.
2) Capture all the sequences like Space, FullStop, Question Mark, Exclamation, Apostrophe, New Line....(May be with RegEx?)
3)Split Words According to the above sequences
4)Get Distinct Words(Occurences) and their count based on the input string in 1st statement.
Desired O/P:
The - 2
DOTNET - 1
Is - 1
Very - 1
Cool - 1
Best - 1
This is my Sample Code for your Ref.
[Code]....
View 3 Replies
Mar 3, 2010
Do I have to get some C# class before taking C# programming lessons?
View 7 Replies
Oct 24, 2010
I just converted an ASP.NET Web Site Project to a Web Application Project in VS 2010. After I run the application though it seems that my class polymorphism broke. I don't have a clue as to why this could occur.
So in the following code when I call base.OnLoad(e) I am getting errors in the base class because the variable myString is null. In fact all the variables for the Base class are null. I can do
[code]....
View 1 Replies
Feb 24, 2010
What is the meaning of this error and how to avoid it:
System.Web.HttpException: Server cannot modify cookies after HTTP headers have been sent.
at System.Web.HttpResponse.BeforeCookieCollectionChange()
at System.Web.HttpCookieCollection.Remove(String name)
at NopSolutions.NopCommerce.Common.NopContext.SetCookie(HttpApplication application, String key, String val) in D:ivolino_3D21012010Nop.CommonNopContext.cs:line 158
at NopSolutions.NopCommerce.Common.NopContext.SessionSaveToClient() in D:ivolino_3D21012010Nop.CommonNopContext.cs:line 127
at NopSolutions.NopCommerce.HttpModules.MembershipHttpModule.Application_EndRequest(Object sender, EventArgs e) in D:WorkOwnNopCommerceSolutionNopCommerceNop.HttpModules.MembershipModuleMembershipHttpModule.cs:line 140
View 3 Replies
Mar 30, 2011
If I have a singleton pattern as follows:
[Code]....
So Let's say User A is logges in first and does a following call:
[Code]....
View 2 Replies
Jan 3, 2011
i cannot understand logic of mvc edit.for example
StudentReposirory students= new StudentReposirory();
// GET: /Student/Edit/5
public ActionResult Edit(int id)
[code]...
View 8 Replies
Feb 18, 2010
i created an intranet based website(information Portal)...i would like to know the pages each user visits and i want track there behavior...what tools should i include..
View 2 Replies
Jan 27, 2010
Don't understand htmlAttributes parameters? try this:
[Code]....
[Code]....
How to correct?
[Code]....
View 11 Replies
Feb 1, 2011
ow to understand whether the visitor is Googlebot or not ? ASP.net 4.0 & C# I mean i want to understand that if the visitor is Googlebot or not.
View 2 Replies
Jan 9, 2010
Until now, I have not create any massive applications using ASP.Net. However, I am looking to create an application that has the potential to be very performance intensive. So I am looking for some tools or best practices when it comes to performance. I would like to be able to know how to: See my current performance (good or bad) View items that need fixing And being able to compare two performance variable items would be great as well.
View 2 Replies
Oct 28, 2010
I have a table with 3 columns Itemid(int),Itemname(string),ItemDesc(string).. Im trying to use a radpanelbar to display this information, where the bar initially shows the item name and on clik/expansion it will show the item description.. I tried looking at the examples on telerik site but didnt understand the point of datafieldid and datafieldparentid. What are they used for and what would their values be for my table.. I tried using different combination of column names for these two ids but I still didnt get it..
View 1 Replies
May 28, 2010
<input type="button" name="reset"
onclick="return ValidateValue(); __doPostBack('ApplyBtn','')" />
The above is the code generated for asp server button button control on browser. Now my query is that irrespective of ValidateValue() returning true/false __doPostBack('ApplyBtn','') function is not showing any effect for me. My understanding is that string passed to onclick acts like function body, and return will from first function will return control preventing second function from execution.
Is that correct?
View 1 Replies
Oct 28, 2010
I understand the concepts of windows workflow...But unable to understand how to implement it...Can anyone tell me some good sites which explains Workflow with coding???
View 1 Replies
May 26, 2010
in my current project I used a AsyncFileUpload control from AJAX Control Toolkits. After I got the async file upload part working, I needed to filter the file type so users can only upload image files. I found the following code off web and it worked well:
[Code]....
The problem is : I don't understand this javascript. What is the type of args parameter? Where are the methods such as "get_fileName()", "set_cancel()" defined? I went to the homepage of the
AsyncFileUpload control but couldn't find any documentation regarding the "args".
View 1 Replies
Apr 20, 2010
how do I understand web service software factory with concrete examples? Is it wcf oriented?
View 4 Replies