Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# - Converting from an interface to an object that implements the interface? -


i have interface implemented several different objects. trying write method in c# accept interface object parameter , convert parameter object implements don't have write same function several different types. such as:

class unappliedcashdetails implements interface itransactiondetail.

constructor issbatch:

public issbatch(list<itransactiondetail> details)

public static issbatch getnextreceiptbatch() { list<unappliedcashdetail> details = new list<unappliedcashdetail>();

    /`*`some code here populate list`*`/                  return = new issbatch(details); 

}

c# not this. trying use interface wrong or not casting correctly?

thanks!

you're passing list<unappliedcashdetail> constructor accepts list<itransactiondetail>. unappliedcashdetail may implement itransactiondetail, type of variance not supported c#. consider inside constructor (or other method) attempt add instance of someothertransactiondetail details list, except details list should really accept unappliedcashdetail, per declaration.

to make code work, need change declaration

list<itransactiondetail> details = new list<itransactiondetail>();       /* code here populate list */                   return new issbatch(details); 

or change constructor accept ienumerable<itransactiondetail>, in case original list<unappliedcashdetail> declaration work. variance supported ienumerable<t> (note: c# 4), since sequence , cannot added to, deleted from, etc., there's no possibility of trying add appliedcashdetail instance sequence of unappliedcashdetail objects.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -