Search

You searched for the word(s): userid:630950

Matching Posts

  • Re: Generic T

    i try to modify the code by not specifing "as T" then i get the below error and if i have "as T" then T is null Error 1 Cannot implicitly convert type 'System.Collections.Generic.List<Person>' to 'T' public T Get(long id) { List<Person> _p = new List<Person>(); DataAccess da = new DataAccess(); _p = da.GetAllPeople(); //as T; return _p; }
    Posted to Getting Started (Forum) by nisarkhan on 11/24/2009
  • Generic T

    I am trying to return the Generic T and its returning null not sure what i'm missing in the below code, any help ? here is my code // public interface IRepositoryGenericT<T> where T : class { T Get(long id); IList<T> GetAll(); void Save(T target); void Delete(T target); } public class RepositoryGenericT<T> : IRepositoryGenericT<T> where T : class { public RepositoryGenericT() { } public T Get(long id) { //id ignore for testing purpose... List<Person> _p = new List<Person>
    Posted to Getting Started (Forum) by nisarkhan on 11/24/2009
  • Re: Generic T

    [quote user="anphme"] The reason that null is being returned is because you are trying to cast a List<Person> as a Person at line 20 and it is failing. There is no built-in conversion of an enumerable type to a non-enumerable type. Try returning the first item in the list (since you are instanciating RepositoryGenericT with type Person at line 48, you do not need to cast the list item). [/quote] I try to change the code as what you have suggust but getting error here is the modified
    Posted to Getting Started (Forum) by nisarkhan on 11/24/2009
  • Re: Generic T

    i change the dataaccess class to accept Generic T but still returning null public class DataAccess<T> where T : class { public T GetAllPeople() { List<Person> persons = new List<Person> { new Person("joe - Memory", "Jatson - Memory", 27), new Person("Ge - Memory", "Page - Memory", 23) }; return persons as T; } } probably i am casting to T ? but if I dont cast it throw me an error: Cannot implicitly convert type 'System.Collections.Generic
    Posted to Getting Started (Forum) by nisarkhan on 11/24/2009
  • Re: Generic T

    i am kind of lost now after reading your last post so my GetAllPeople is nothing but: public class DataAccess//<T> { public List<Person> GetAllPeople() { List<Person> persons = new List<Person> { new Person("joe - Memory", "Jatson - Memory", 27), new Person("Ge - Memory", "Page - Memory", 23) }; return persons; } } public class Person { public Person(string firstname, string lastname, int age) { Firstname = firstname; Lastname = lastname;
    Posted to Getting Started (Forum) by nisarkhan on 11/24/2009
  • Re: IENumerable selecting indexes

    have you tried Element or ElementAt ?
    Posted to C# (Forum) by nisarkhan on 11/6/2009
  • Re: video training course

    you can try appdev.com but bit expensive thou or learnvisualstudio.net is cheap and best but they rarely updat their videos.
    Posted to Book Reviews (Forum) by nisarkhan on 10/26/2009
  • Re: videos better than books?

    [quote user="Nelson85"] Do you think videos are better than books? [/quote] video to get quick start and then later you can read book to get into more detail.
    Posted to Book Reviews (Forum) by nisarkhan on 10/26/2009
  • Re: IQueryable

    i saw those post before i posting here and i dont find what i'm curious to know.
  • Re: linq2sql whats wrong here?

    [quote user="gunteman"] In that case IEnumerable is the right choice, but isn't "Id" the primary key? Can sp_Visit(Id) really return more than one? PS. You should not name procedures with "sp_", it's reserved for MSSQL internal system procedures. It will actually become a bit slower, since the master database will be checked automatically, due to the prefix. [/quote] "sp_" i use just to for the purpose of highlighting that i'm using stored procedure
    Posted to Architecture (Forum) by nisarkhan on 10/21/2009
Page 1 of 136 (1351 items) 1 2 3 4 5 Next > ... Last »