logo logo
Home arrow Robotics Studio... arrow Robotics Developer Studio Resources and Howto arrow How to use the new features of C# 2.0
Saturday, 11 February 2012
 
 
Main Menu
Home
Conscious Machines...
AI Techniques...
Neuroscience...
Researchers...
Publications...
Reviews...
MC Bibliography
Robotics Studio...
Forums...
Blog...
Frontpage
Upcoming Events
22.Feb. 2012

CogSys 2012
Vienna, Austria
04.Apr. 2012

TSC 2012
Tucson, Arizona
17.May. 2012

EAIS 2012
Madrid, Spain
05.Jun. 2012

Cognition & Consciousness
Menorca. Spain
02.Jul. 2012

ASSC 16
Brighton, UK
02.Jul. 2012

Revisiting Turing and his Test
Birmingham, UK
31.Oct. 2012

BICA 2012
Palermo. Italy
Tag Cloud
Associations Books Conferences Conscious Conscious Machines Consciousness Developer Documentación Documentation Español Machine Machine Consciousness Machines Neuroscience Positions Publications Research Researchers Reviews Robotics Robots Spanish Studio VPL
Spotlight
More
Reader's Preferred
MCexperts List
FAQs
Glossary
Site Map
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:
 
 

 

 

 

 


Add as favourites (216) | Quote this article on your site | Views: 6750

  Be first to comment this article
RSS comments

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


Related Items:

  1. How to change my password?
  2. New anesthesia derived from chillis block pain without impairing movement
  3. Jobs: Two Chair positions for new Centre for Computational Neuroscience and Co
  4. Birmingham Fellows in Robotics and Cognitive Systems
  5. Finding papers about consciousness and robotics
  6. The APA Newsletter on Philosophy and Computers
  7. APA Newsletter: Phenomenal Machine Consciousness
  8. Paladyn. Journal of Behavioral Robotics
  9. International Journal of Social Robotics
  10. Cognitive Robotics and Machine Consciousness
Last Updated ( Thursday, 20 December 2007 )
 





Lost Password?
No account yet? Register
 Conscious Robots RSS FeedConscious Robots RSS Feed

Find us on Facebook

Follow us on TwitterFollow us on twitter
Spotlight

Machine Consciousness Bibliography Database

 

ConsScale
The Cognitive Machine Consciousness Scale

 
Categories
Last Posts in Forum
 
CR
miel continental