// ===++===
//
// OrtizOL
//
// ===--===
/*============================================================
//
// Clase: StructsComoArgumentos.cs
//
// Propósito: Observar el efecto de pasar un tipo struct
// como argumento en un método.
//
============================================================*/
using System;
public struct MiStruct
{
public double Campo;
}
public class MiClase
{
public double Campo;
}
public class DemoStruct
{
public static void Main()
{
MiStruct ms = new MiStruct();
MiClase mc = new MiClase();
// Asignación de valores a los campos
ms.Campo = 3;
mc.Campo = 3;
CambiarValorStruct(ms);
CambiarValorClase(mc);
// Muestra valores en la salida estándar
Console.WriteLine("Valor de ms.Campo = {0}", ms.Campo);
Console.WriteLine("Valor de mc.Campo = {0}", mc.Campo);
}
public static void CambiarValorStruct(MiStruct arg)
{
arg.Campo = 7;
}
public static void CambiarValorClase(MiClase arg)
{
arg.Campo = 7;
}
}
Ly8gPT09Kys9PT0KLy8KLy8JT3J0aXpPTAovLwovLyA9PT0tLT09PQovKj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQovLwovLyBDbGFzZTogU3RydWN0c0NvbW9Bcmd1bWVudG9zLmNzCi8vCi8vIFByb3DDs3NpdG86IE9ic2VydmFyIGVsIGVmZWN0byBkZSBwYXNhciB1biB0aXBvIHN0cnVjdAovLyBjb21vIGFyZ3VtZW50byBlbiB1biBtw6l0b2RvLgovLwo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0qLwoKdXNpbmcgU3lzdGVtOwoKcHVibGljIHN0cnVjdCBNaVN0cnVjdAp7CglwdWJsaWMgZG91YmxlIENhbXBvOwp9CgpwdWJsaWMgY2xhc3MgTWlDbGFzZQp7CglwdWJsaWMgZG91YmxlIENhbXBvOwp9CgpwdWJsaWMgY2xhc3MgRGVtb1N0cnVjdAp7CglwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCgl7CgkJTWlTdHJ1Y3QgbXMgPSBuZXcgTWlTdHJ1Y3QoKTsKCQlNaUNsYXN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