IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

C# Error CS1061


Sujet :

C#

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 15
    Points : 9
    Points
    9
    Par défaut C# Error CS1061
    Bonjour,
    Etant débutant en C#
    Je suis confronté a un problème qui me bloque pas mal...
    Si vous pouviez m'éclairer sur la marche a suivre.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
     
    public class TvCategory
    {
     
    	public class TvCategoryEntry
    	{
    		public string id_rub_list;
    		public string rub_en;
    		public string rub_fr;
    		public string rub_ar;
    		public string rub_th;
    		public string rub_jp;
    		public string picture;
    		public string thumbnail;
    		public string summary_en;
    		public string summary_fr;
    		public string summary_ar;
    		public string summary_th;
    		public string summary_jp;
    		public string trailer;
    		public string offer_start;
    		public string offer_stop;
    		public string offer_length;
    		public string price;
    		public string usage;
    	}
     
    	public class TvCategoryArray
    	{
    		public IList<TvCategoryEntry> Categories{ get; set; }
    	}
     
    	public TvCategory ()
    	{
    	}
     
    	public  void TVcategoryRequest()
    	{
    		string url	= "http://127.0.0.1/mobileApp/php/channelCategories.php";
    		var request = WebRequest.Create(url); 
    		string text;
    		var response = (HttpWebResponse) request.GetResponse();
     
    		using (var sr = new StreamReader(response.GetResponseStream()))
    		{
    			text = sr.ReadToEnd();
    			Console.WriteLine("text2"+text);
    		}
    		TvCategoryArray Cat = (TvCategoryArray)Deserialize<TvCategoryArray>(text);
    		Console.WriteLine("test3"+ Cat.Categories);
    	}
     
    	public static TvCategoryArray Deserialize<TvCategoryArray>(string jsonString)
    	{
    		using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(jsonString)))
    		{
    			DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(TvCategoryArray));
    			//Console.WriteLine("TEST4"+ms);
    			var results = (TvCategoryArray)serializer.ReadObject(ms);
    			foreach(var test in  results.Categories)
    			{
    				Console.WriteLine("TESTCACA"+test.id_rub_list);
    			}
    			return ((TvCategoryArray)results);
    		}
    	}
    }
    Me génère l'erreur suivante:
    d:\Project\PSS\UI\MainMenu\MainMenu.cs(35,35): Error CS1061: 'TvCategoryArray' does not contain a definition for 'Categories' and no extension method 'Categories' accepting a first argument of type 'TvCategoryArray' could be found (are you missing a using directive or an assembly reference?) (CS1061) (VianeosUI)
    Hors il me semble que la classe TvCategoryArray contient bien une variable de type Categories.
    Merci d'avance pour toute aide apporté.

  2. #2
    Membre expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Points : 3 568
    Points
    3 568
    Par défaut
    c'est parce que TvCategoryArray est un type imbriqué (inner class).

    Ajoute le nom de la classe parent,et ça ira. Exemple :

    Code C# : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    var results = (TvCategory.TvCategoryArray)serializer.ReadObject(ms);
    Microsoft MVP : Windows Platform

    MCPD - Windows Phone Developer
    MCPD - Windows Developer 4

    http://www.guruumeditation.net

    “If debugging is the process of removing bugs, then programming must be the process of putting them in.”
    (Edsger W. Dijkstra)

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2008
    Messages
    15
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2008
    Messages : 15
    Points : 9
    Points
    9
    Par défaut
    Merci c'était effectivement ca.
    Bon en avant pour d'autres horizon plein d'Acces Violation & coe

Discussions similaires

  1. ERROR: pg_atoi: zero-length string
    Par steelspirit92 dans le forum PostgreSQL
    Réponses: 1
    Dernier message: 23/08/2003, 22h29
  2. [SQL Server] Error converting data type varchar...
    Par Sir Tengu dans le forum MS SQL Server
    Réponses: 9
    Dernier message: 13/06/2003, 10h46
  3. [Kylix] Kylix c++ error
    Par pacpac dans le forum EDI
    Réponses: 2
    Dernier message: 10/06/2003, 16h27
  4. [CR] Print Engine error text
    Par afaraji dans le forum SAP Crystal Reports
    Réponses: 1
    Dernier message: 03/09/2002, 15h44
  5. [Kylix] Runtime error 230 avec INDY
    Par Anonymous dans le forum EDI
    Réponses: 2
    Dernier message: 23/03/2002, 11h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo