Cannot implicity convert type void to string

Cannot implicity convert type void to string

offline
  • Pridružio: 09 Okt 2014
  • Poruke: 5

Pozdrav, imam problem sa greskom u kodu? Kako da resim to?

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace multiplicationGUI
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.  
  23.             int userInput;
  24.             userInput = Convert.ToInt32(txtUserInput);
  25.             lblResults.Text = MultiplicationTable(userInput);
  26.         }
  27.       
  28.       private void MultiplicationTable(int input)
  29.       {
  30.          int[] numbers = {2,3,4,5,6,7,8,9,10};
  31.          for (int x = 0; x < numbers.Length; x++)
  32.          {
  33.             int results;
  34.             results = input*(numbers[x]);
  35.                 Console.WriteLine("{0} X {1} = {2}", input.ToString("N0"), numbers[x].ToString("N0"), results.ToString("N0"));
  36.          }
  37.       }
  38.  
  39.         private void btnExit_Click(object sender, EventArgs e)
  40.         {
  41.             this.Close();
  42.         }
  43.     }
  44. }



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • Srđan Tot
  • Am I evil? I am man, yes I am.
  • Pridružio: 12 Jul 2005
  • Poruke: 2483
  • Gde živiš: Ljubljana

Funkcija MultiplicationTable ne vraća nikakvu vrednost pa zato ne možeš da je iskoristiš da postaviš lblResults.Text. Popravi funkciju tako da vrati string koji želiš da prikažeš u lblResults.Text.



Ko je trenutno na forumu
 

Ukupno su 888 korisnika na forumu :: 63 registrovanih, 10 sakrivenih i 815 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: aleksmajstor, Asteker, Bojadin Strumski, Cigi, Cirkon, cole77, dankisha, Dimitrise93, DonRumataEstorski, Dovla 1980, dule10savic, dzoni19, esko_hz, gagidjuric, Gargamel008, Georgius, Helket, hellenic, Ir, ivanR164, Jakonjveliki, Kajzer Soze, kib, Kibice, loon123, Makarid, Makeitdrip, marera, MB120mm, mercedesamg, Milan A. Nikolic, moldway, mrav pesadinac, Mskok, Ne doznajem se u oružje, nelezele, Nikola0575, nikolapetkovic, Niske, nnovakis, Obrad2, Orc, Paklenica, Povratak1912, Prašinar, repac, S.Palestinac, S2M, samo opusteno, saputnik plavetnila, Sarmat, sspp, stefan95, strn, t84dar, theNedjeljko, Token, Vlada1389, voja64, vukovi, zlaya011, zziko, 800077