Hello there DaniWeb, im switching from vb.net to c# and i think its alot better already, i just wonder about a thing

How can i insert data into a variabel?

this is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Net;

namespace LottoClient
{

    public partial class frm_main : Form
    {
        #region Dims
        // Random Function
        new Random rndfunc;
        // createTicket
        [B]string createTicket_output;[/B]
       
        //Ticket downloads
        new WebClient wc;
        #endregion
       

        #region Actions
    private void createTicket
    {
        [B]createTicket_output = "test";[/B]
           [B]//The code above doesnt work[/B]
    }

        #endregion

        public frm_main()
        {
            InitializeComponent();
        }

        private void frm_main_Load(object sender, EventArgs e)
        {
            log("Welcome to LottoClient");
        }

        #region Logging
        public void log(string msg)
        {
            lb_log.Items.Add(DateTime.Now.Hour + (":"
                + (DateTime.Now.Minute + (":"
                  + (DateTime.Now.Second + " - " + msg)))));
        }
        #endregion
       
    }
}

Recommended Answers

All 5 Replies

What do you mean by "doesn't work"? There is nothing wrong with the syntax and you never use the variable in your code so how would you know if it 'worked' or not?

on createTicket_output = "test"; i recieve


Error 1 A get or set accessor expected

private void createTicket
    {
        createTicket_output = "test";
           //The code above doesnt work
    }

Your problem is line 1. What you are doing here is creating a Property and properties require get/set methods. What it should be is:

private void createTicket()
    {
        createTicket_output = "test";
           //The code above doesnt work
    }

Notice the opening/closing () on the first line which declares this as a method, rather than a property.

commented: perfect answer, who voted negative here? +8

Thank you! :)

Shit, i voted wrong on your answer, any chance that i can revert it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.