with-statements

Top  Previous  Next

What is translated > Statements > with-statements

 

In C# there are no with-statements. Therefore Delphi2C# inserts a temporary helping variable of the with-type. This type is easily obtained by use of the C#11 auto keyword:

 

 

type TDate = record         ->         struct TDate {                              

  Day: Integer;                          int Day;                                  

  Month: Integer;                        int Month;                                

  Year: Integer;                         int Year;                                 

end;                                   };                                          

                                            

procedure test(OrderDate: TDate);      void Test(TDate OrderDate)            

begin                                  {                                     

  with OrderDate do                      /*# with OrderDate do */            

    if Month = 12 then                   {                                   

    begin                                  auto& with0 = OrderDate;          

      Month := 1;                          if(with0.Month == 12)             

      Year := Year + 1;                    {                                 

    end                                      with0.Month = 1;                

    else                                     with0.Year = with0.Year + 1;    

      Month := Month + 1;                  }                                 

end;                                       else                              

                                            with0.Month = with0.Month + 1;    

                                         }                                   

                                       }                                     

 

 

 



This page belongs to the Delphi2C# Documentation

Delphi2C# home  Content