GET /blog/Sneak-peek-at-K.md text/markdown back to the human version
---
title:        "Sneak peek at K#"
description:  "With the 6.0 beta being out for a couple of days, I thought it was time to take a better look at some of the new features. One feature that I am really looking forward to use is the new K# engine. In this post I will cover a couple of examples using K#."
url:          https://www.jeroenfurst.nl/blog/Sneak-peek-at-K
date:         2011-08-23
category:     Macros and K#
tags:         [Macros and K#]
reading_time: 1
---

# Sneak peek at K#

> With the 6.0 beta being out for a couple of days, I thought it was time to take a better look at some of the new features. One feature that I am really looking forward to use is the new K# engine. In this post I will cover a couple of examples using K#.

With the 6.0 beta being out for a couple of days, I thought it was time to take a better look at some of the new features. One feature that I am really looking forward to use is the new K# engine. In this post I will cover a couple of examples using K#.
 
 **1. Methods**
 
 The newly improved Macro editor not only displays a list of available Macros, but it also shows you a list of methods that you can use. Take for example the GetUserFullName method that takes a User's ID and returns the User's Full Name:
 
 *{% GetUserFullName(CurrentUser.UserID) %}* 
 
 The macro and it's result are illustrated in the following screenshot:
 
 ![ksharp_example_1.png](~/getContentAsset/dba188f8-8f9c-4fbf-9347-58cbbfe011e8/310c1ea5-13ca-4d75-95a0-620f51989b44/21d3db5c_ksharp_example_1.png.png)
 
 **2. foreach loop**
 
 K# supports some well known commands like if statements, for loops, while loops and foreach loops. In the example below I loop through all the children of the document root and output every documents name (MenuItemName).
 
 *{% ret = ""; foreach(x in RootDocument.Children) { ret += x.MenuItemName} ret %}*
 
 ![ksharp_example_2.png](~/getContentAsset/bc4b6a6a-8e06-420d-b8c7-694a4ceaab6d/310c1ea5-13ca-4d75-95a0-620f51989b44/b2cb4d63_ksharp_example_2.png.png)
 
 **3. Comments**
 
 You can add some comments to your code similar to C#:
 
 *{% 
 ret = ""; 
 
 // Loop through the children
 foreach(x in RootDocument.Children) 
 { 
 // Add the MenuItemName
 ret += x.MenuItemName
 } 
 
 ret 
 %}*
 
 ![ksharp_example_3.png](~/getContentAsset/6905000d-9b3a-4f94-88f0-e9eea06d5510/310c1ea5-13ca-4d75-95a0-620f51989b44/54eb4340_ksharp_example_3.png.png)
 
 **4. Lorem Ipsum**
 
 Version 6.0 brings you the "Lorem Ipsum" macro! Simply use the following syntax to generate the Lorem ipsum text:
 
 *{%LoremIpsum%}*
 
 ![ksharp_example_4.png](~/getContentAsset/2deea593-47b0-48fa-afdc-1c432869693b/310c1ea5-13ca-4d75-95a0-620f51989b44/33fb6c23_ksharp_example_4.png.png)
 
 **5. Transformations**
 
 It will be possible to use Macros in transformations if you choose a Macro supporting transformation type like HTML. Known syntaxes like the following will be possible without additional code (CMS.CMSHelper.CMSContext.CurrentResolver.ResolveMacros(string inputText)):
 
 *{%NewsTitle%}* 
 
 ![ksharp_example_5.png](~/getContentAsset/c9baea32-4c8e-4f25-9fce-5795d763dd12/310c1ea5-13ca-4d75-95a0-620f51989b44/7a41987d_ksharp_example_5.png.png)
 
 That concludes the sneak peek at K#. I hope these examples will give you an idea of what's to come and I am looking forward to provide you with more examples once I can use K# in practise. K# is definitely in my top 3 list of best 6.0 features!