Home > OS >  how to return an object in c#?
how to return an object in c#?

Time:07-07

I'm filling data inside an object with c# but I don't know how to return this object. I create an object named ArasOrder and fill in the data and I want to return the ArasOrder object. how can I do this.

public class ArasDeneme
{
    public static void aras()
    {
        var ArasService = new ArasTEST.Service();
        var ArasGonderi = new ArasTEST.ShippingOrder();
        var ArasOrder = new ArasTEST.Order();
        var parametreler = ArasKargoTEST.ParametreGet();
        var newentegrationcode = "";
        foreach (var item in parametreler)
        {
            var encode = entegrationcode();
            var YeniGelenDesi = DesiHesabi(item.WebSiparisNo);

            var yeniteminyeri = item.TeminYeri;
            newentegrationcode = 123  ""   encode;
            ArasOrder.UserName = "";
            ArasOrder.Password = "";
            ArasOrder.ReceiverName = item.KargoAdSoyad;
            ArasOrder.ReceiverPhone1 = item.KargoTelefon;
            ArasOrder.ReceiverCityName = item.KargoIlAdi;
            ArasOrder.ReceiverTownName = item.KargoIlceAdi;
            ArasOrder.ReceiverAddress = item.KargoAdres;
            ArasOrder.TradingWaybillNumber = item.WebSiparisNo;
            ArasOrder.PieceCount = "1";
            ArasOrder.IntegrationCode = newentegrationcode;
            ArasOrder.PayorTypeCode = "1";
            ArasOrder.IsWorldWide = "0";
            ArasOrder.IsCod = "0";
            ArasOrder.VolumetricWeight = YeniGelenDesi;
            ArasOrder.SenderAccountAddressId = "1071";
            ArasTEST.PieceDetail[] ArasPieceDetails = new ArasTEST.PieceDetail[1];
            PieceDetail ArasPieceDetail1 = new PieceDetail();
            ArasPieceDetail1.BarcodeNumber = newentegrationcode;
            ArasPieceDetail1.VolumetricWeight = YeniGelenDesi;
            ArasPieceDetail1.Weight = "1";
            ArasPieceDetail1.Description = "";
            ArasPieceDetails[0] = ArasPieceDetail1;
            ArasOrder.PieceDetails = ArasPieceDetails;
            var ArasOrderInfo = new ArasTEST.Order[1];
            ArasOrderInfo[0] = ArasOrder;
            var takipNoResult = ArasService.SetOrder("", "", "");
            var ArasOrderResultInfo = takipNoResult[0];
            var SonucKodu = takipNoResult[0].ResultCode;
            var SonucMesaji = takipNoResult[0].ResultMessage;
            var SonucInvoiceKey = takipNoResult[0].InvoiceKey;
        }
    }
}

CodePudding user response:

You should define the return type and return the instance.

public static ArasTEST aras()
{
    // insert code here...


    return ArasOrder;
}

CodePudding user response:

Change void to ArasDeneme return type.

Then call like:

var ad = ArasDeneme.aras();

  • Related