Ice for C#
The comprehensive features of the Ice platform are available to .NET developers using Ice for C#. A native C# implementation of Ice provides compatibility with Visual C# as well as Mono, while the Common Language Runtime enables seamless support for Visual Basic .NET.
C#
On the strength of Microsoft's product support, C# has quickly grown to prominence as an effective tool for developing Windows applications and Web services. As a result, Ice for C# is an excellent platform for integrating Ice services with enterprise technologies such as ASP.NET and SOAP.
Sample Code
To illustrate how Ice is used in various language mappings, consider the following Slice interface definitions:
module Biz {
struct Item {
string sku;
int qty;
};
sequence<Item> ItemSeq;
interface Invoice {
void addItems(ItemSeq items);
void submit();
};
interface InvoiceFactory {
Invoice* create();
};
};
C# code that creates an invoice using the factory is shown below:
// Create a proxy for the invoice factory object.
Ice.ObjectPrx proxy = communicator.stringToProxy("InvoiceFactory:tcp -p 9000");
// Narrow the proxy to the proper type.
Biz.InvoiceFactoryPrx factory = Biz.InvoiceFactoryPrxHelper.checkedCast(proxy);
// Use the factory to obtain a proxy for a new invoice object.
Biz.InvoicePrx invoice = factory.create();
// Add items to the invoice.
Biz.Item[] items = new Biz.Item[1];
items[0].sku = "10-6139";
items[0].qty = 3;
invoice.addItems(items);
// Submit the invoice.
invoice.submit();