# CLR Properties in IronRuby

**URL:** <https://www.ruby-forum.com/t/clr-properties-in-ironruby/176056>\
**Category:** IronRuby\
**Created:** [September 24, 2009, 5:59am UTC](https://www.ruby-forum.com/t/clr-properties-in-ironruby/176056 "2009-09-24T05:59:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 24, 2009, 5:59am UTC](https://www.ruby-forum.com/t/clr-properties-in-ironruby/176056/1 "2009-09-24T05:59:56Z")

</div>

How can I refer to the CLR properties in IronRuby.  
public class Customer {

public string FirstName { get;set; }

}

In Ruby:

@customer.FirstName = ‘s’

OR

@customer.firstname = ‘s’

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 24, 2009, 6:15am UTC](https://www.ruby-forum.com/t/clr-properties-in-ironruby/176056/2 "2009-09-24T06:15:09Z")

</div>

@customer.first\_name = ‘s’  
This is called name mangling when IronRuby make CLR name Ruby-like.

## Shay.

Shay F.  
Author of “IronRuby Unleashed”  
[http://www.IronShay.com](http://www.IronShay.com)  
Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)

---

<div class="post-metadata">

**Author:** ![metanoize](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9fc29f/32.png) [@metanoize](https://www.ruby-forum.com/u/metanoize)\
**Post date:** [September 24, 2009, 6:23am UTC](https://www.ruby-forum.com/t/clr-properties-in-ironruby/176056/3 "2009-09-24T06:23:21Z")

</div>

C:\temp  
[42] \> rbd  
IronRuby 0.9.0.0 on .NET 2.0.50727.4927  
Copyright (c) Microsoft Corporation. All rights reserved.

> > > require ‘temp.dll’  
> > > =\> true  
> > > @c = Customer.new  
> > > =\> Customer  
> > > @c.FirstName  
> > > =\> nil  
> > > @c.first\_name  
> > > =\> nil  
> > > @c.FirstName = ‘s’  
> > > =\> “s”  
> > > @c.first\_name  
> > > =\> ‘s’  
> > > @c.FirstName  
> > > =\> ‘s’  
> > > @c.first\_name = ‘s’  
> > > =\> “s”  
> > > @c.first\_name  
> > > =\> ‘s’  
> > > @c.FirstName  
> > > =\> ‘s’

In particular, IR mangles CamelCase into snake\_case for most .NET  
methods, but it doesn’t work for pure Ruby methods. In addition, certain  
builtin types, such as Object and Fixnum are the same type as  
System.Object and System.Int32 (respectively), so they don’t mangle  
names. When in doubt, you should always be able to call a method by its  
proper .NET name, and you can use #methods to get a list of the methods  
that an object responds to. (in this case, @c.methods would have  
‘first\_name’ and ‘first\_name=’ method in the list.

JD

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Shay F.  
Sent: Wednesday, September 23, 2009 9:14 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] CLR Properties in IronRuby

@customer.first\_name = ‘s’

This is called name mangling when IronRuby make CLR name Ruby-like.

## Shay.

Shay F.  
Author of “IronRuby Unleashed”  
[http://www.IronShay.com](http://www.IronShay.com)  
Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)  
On Thu, Sep 24, 2009 at 6:59 AM, Mohammad A.  
\<removed\_email\_address@domain.invalid[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> wrote:  
How can I refer to the CLR properties in IronRuby.

public class Customer {

public string FirstName { get;set; }

}

In Ruby:

@customer.FirstName = ‘s’

OR

@customer.firstname = ‘s’

–  
Mohammad A.  
MVP (Microsoft Valuable Professional)  
[www.highoncoding.com](http://www.highoncoding.com)[http://www.highoncoding.com](http://www.highoncoding.com)  
[www.azamsharp.com](http://www.azamsharp.com)[http://www.azamsharp.com](http://www.azamsharp.com)
