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# - using List<T>.Find() with custom objects -


i'm trying use list<t> custom class of mine, , being able use methods contains(), find(), etc., on list. thought i'd have overload operator == apparently, 1 way of doing use delegate method find()...

note: right now, i've overloaded equals() method contains() method work, still couldn't find() function work.

what best way of getting both work?

i'm using latest c# /.net framework version mono, on linux.

edit: here's code

using system; namespace guerredesclans { public class reponse : iequatable<reponse> {     public reponse ()     {         m_statement = string.empty;         m_pointage = 0;     }      public reponse (string statement, int pointage)     {         m_pointage = pointage;         m_statement = statement;     }       /*      * attributs privés      */      private string m_statement;     private int m_pointage;       /*      * properties      */      public string statement {         { return m_statement; }         set { m_statement = value; }     }      public int pointage {         { return m_pointage; }         set { m_pointage = value; }     }      /*      * equatable      */      public bool equals (reponse other)     {         if (this.m_statement == other.m_statement)             return true;         else             return false;     } } 

}

and how search reponse objects using find() function...

list.find("statement1"); // return reponse object 

find() find element matches predicate pass parameter, not related equals() or == operator.

var element = mylist.find(e => [some condition on e]); 

in case, have used lambda expression predicate. might want read on this. in case of find(), expression should take element , return bool.

in case, be:

var reponse = list.find(r => r.statement == "statement1") 

and answer question in comments, equivalent in .net 2.0, before lambda expressions introduced:

var response = list.find(delegate (response r) {     return r.statement == "statement1"; }); 

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 -