2016-12-29 17 views
-2

新一類ManageFilms創建功能«GetFilmByName»的參數至極返回電影中,標題爲參數功能C#中,創建一個功能«GetFilmByName»新一類ManageFilms至極返回一個電影中,標題是函數

namespace CinemaCore 
{ 
    public class Film 
    { 
     public int ID { get; set; } 
     public string Titre { get; set; } 
     public DateTime DateSortie { get; set; } 
     public string Realisateur { get; set; } 
     public string Genre { get; set; } 
     public TimeSpan Duree { get; set; } 

     public Film(int ID ,string Titre, DateTime DateSortie,string Realisateur,string Genre,TimeSpan Duree) 
     { 
      this.ID = ID; 
      this.Titre = Titre; 
      this.DateSortie = DateSortie; 
      this.Realisateur = Realisateur; 
      this.Genre = Genre; 
      this.Duree = Duree; 
     } 

     public override string ToString() 
     { 
      return "the id is :"+ID+"the titel is :"+Titre+"Date to show "+DateSortie+"Realisateur :"+Realisateur+"Genre :"+Genre+"Time"+Duree; 
     } 
    } 
} 

//這是新的類ManageFilms

namespace CinemaCore 
{ 
    public class ManageFilms 
    { 
     List<Film> films = new List<Film>(); 
     public Film GetFilmByName(Film f1) 
     { 

     } 
    } 
} 
+3

下去的話,創建它... – buffjape

+0

我不知道如何! –

+0

學習並嘗試自己先做。如果您有特定的問題,請提出有關該問題的問題。 Stackoverflow不是一個代碼寫入服務。 – buffjape

回答

-1

試試這個:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 

namespace CinemaCore 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
     } 
    } 
    public class Film 
    { 
     private static List<CinemaCore.Film> films = new List<Film>(); 
     public int ID { get; set; } 
     public string Titre { get; set; } 
     public DateTime DateSortie { get; set; } 
     public string Realisateur { get; set; } 
     public string Genre { get; set; } 
     public TimeSpan Duree { get; set; } 

     public Film() { } 

     public Film(int ID, string Titre, DateTime DateSortie, string Realisateur, string Genre, TimeSpan Duree) 
     { 
      this.ID = ID; 
      this.Titre = Titre; 
      this.DateSortie = DateSortie; 
      this.Realisateur = Realisateur; 
      this.Genre = Genre; 
      this.Duree = Duree; 


     } 
     public List<Film> GetFilmByName() 
     { 
      return films.OrderBy(x => x.Titre).ToList(); 
     } 

     public override string ToString() 
     { 
      return string.Format("the id is : '{0}' the titel is : '{1}' Date to show : '{2}' Realisateur : '{3}' Genre : '{4}' Time : '{5}", 
       ID, Titre, DateSortie, Realisateur, Genre, Duree); 
     } 
    } 
    public class ManageFilms 
    { 
     Film film = new Film(); 
     public ManageFilms() 
     { 
      List<Film> films = film.GetFilmByName(); 
     } 

    } 
} 
相關問題