V
V
Vlad Osadchyi2018-02-25 23:55:28
C++ / C#
Vlad Osadchyi, 2018-02-25 23:55:28

Can't call a function from another function?

Does not call XArF() in private void button1_Click(object sender, EventArgs e)
Error CS0103 The name 'XArF' does not exist in the current context.
P.S. don't worry, i'm learning...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            XArF();
        }

        public RichTextBox getRichTextBox1()
        {
            return richTextBox1;
        }

    }

    public class Main : Form1
    {
        public double[] xAr;

        public void XArF()
        {
            int n = getRichTextBox1().Lines.Length;
            int k = 0;

            for (int i = 0; i < n; i++)
            {
                xAr[k] = Convert.ToInt32(getRichTextBox1().Lines[i]);
                k++;
            }
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-02-26
@VladOsadchyi

This method is defined in the descendant. And, of course, the base class does not have access to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question