logo logo
Home arrow Robotics Studio... arrow Robotics Studio Howto arrow How to use the new features of C# 2.0
Friday, 21 November 2008
 
 
English English  Español Español  
Upcoming Events
10.Jun. 2009

IWANN 2009
Salamanca, Spain
International Work-Conference on Artificial Neural Networks
11.Jun. 2009

Toward a Science of Consciousness
Hong Kong, China
15.Jun. 2009

International Workshop on Machine Consciousness
Hong Kong, China
15.Jun. 2009

The 8th IEEE International Conference on Cognitive Informatics
Hong Kong, China
22.Jun. 2009

IWINAC 2009
Santiago de Compostela, Spain
Work-Conference in the Interplay between Natural and Artificial Computation
Tag Cloud
Architectures Artificial Associations Books Brain Conferences Conscious Consciousness Forums Howto Machine Machine Consciousness Machines Microsoft Neuroscience Projects Publications Research Researchers Reviews Robotics Robots Services Studio
Spotlight
Syndicate
 Conscious Robots RSS FeedConscious Robots RSS Feed
How to use the new features of C# 2.0 Print E-mail
Written by Raúl Arrabales Moreno   
Thursday, 20 December 2007

When you look for the first time to the C# sample code provided  with Robotics Studio you will notice that  some new features of this language are extensively used.  Statements like yield return, yield break, and IEnumerator<ITask> might call your attention.

 
Basically, all of this is about Iterators. If you are new to C# 2.0 and want to program robotics applications using Robotics Studio you should clearly understand how Iterators are used.
 
Iterators can be methods, get accessors or operators that support foreach interation in a class. Usually, if you want to use the foreach statement with a given class you need to implement the IEnumerable interface. However, using Iterators allows you to support foreach iteration in a class without having to implement the entire IEnumerable interface. You just need to write an iterator able to sequentially access the data structures contained in your class. The Visual Studio compiler detects iterators and automatically generates the IEnumerable methods  CurrentMoveNext and Dispose.
 
When writting iterators code, the statement yield return is used to return each element in turn, while yield break ends the iteration. The elements returned by yield return <expression> have to be of type IEnumerable or IEnumerator. In the case of Robotics Studio, when we are using the CCR, we usually return a IEnumerator<ITask> (as the generics IEnumerable<T> and IEnumerator<T> can also be used with iterators). Basically, what we are doing is dispatching a collection of tasks.
 
Have a look to the following links for a detailed explanation and sample code:
 
 

 

 

 

 


Related Items:

  1. Microsoft Robotics Studio Pages
  2. How to change my password?
  3. New anesthesia derived from chillis block pain without impairing movement
  4. Finding papers about consciousness and robotics
  5. Cognitive Robotics and Machine Consciousness
  6. Cognitive Robotics
  7. Polymorphic Robotics
  8. New version of Asimo in Barcelona
  9. AMOUSE The Robotic Mouse
  10. 1st International Seminar on New Issues of AI

Add as favourites (83) | Quote this article on your site | Views: 2666 | E-mail

  Be first to comment this article
RSS comments

Only registered users can write comments.
Please login or register.

Last Updated ( Thursday, 20 December 2007 )
 





Lost Password?
No account yet? Register
Categories
Last Posts in Forum
 
Top!
Advertising links: Cheap Gas - Loans - United Specialties - Loans
Top!