cfrank2000
Well-known member
- Joined
- Mar 6, 2021
- Messages
- 71
- Programming Experience
- Beginner
Hi
thank you for helping me previously. at the moment I am facing a conversion issue. I managed to get the list of characters to check its characters against another string to count the same characters. I need help in this matter.
the faulty part is :
if (dt2.kar == str1[i2])
{
mydata.a += 1;
tmb2.Add(mydata);
}
I can see the error but I need help to correct it to make this app. running.
thank you.
thank you for helping me previously. at the moment I am facing a conversion issue. I managed to get the list of characters to check its characters against another string to count the same characters. I need help in this matter.
the faulty part is :
if (dt2.kar == str1[i2])
{
mydata.a += 1;
tmb2.Add(mydata);
}
I can see the error but I need help to correct it to make this app. running.
thank you.
data type conversion:
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApp2karater1
{
class Program
{
class mystruct{
public string kar;
public int a;
}
static void Main(string[] args)
{
int[] a = new int[14];
int i = 0;
int j = 0;
int k = -1;
int hossz = 0;
string[] tomb = new string[14];
List<mystruct> tmb2 = new List<mystruct>();
int[] tomb2 = new int[14];
string str1 = "hello world!?/";
string str2 = "";
mystruct[] tmb = new mystruct[14];
hossz = str1.Length;
mystruct myrek = new mystruct();
for (i = 0; i < hossz; i++)
{
for (j = 0; j < hossz; j++)
{
if (str1[j] == str1[i])
{
a[j] = a[j] + 1;
if (a[j] < 2)
{
//k = k + 1;
tomb[i] = Convert.ToString(str1[i]);
tomb2[i] = 1;
k = k + tomb2[i];
//tmb.kar[i]=str1[i];
//str2+=str1[i];
}
else
{
tomb[i] = "empty";
}
}
}
Console.Write(a[i] + " i " + i + " k " + k + " " + tomb[i] + " " + tomb2[i] + " \n");
}
k = 0;
for (i = 0; i < hossz; i++)
{
tomb2[i] = tomb2[i] + 1;
Console.Write(" a[" + i + " ] " + a[i] + " " + tomb[i]);
Console.Write(" " + tomb2[i] + "\n");
if (tomb[i] != "empty")
{
mystruct mydata = new mystruct();
str2 += tomb[i];
mydata.kar +=tomb[i];
tmb2.Add(mydata);
}
}
foreach (char ch in str2)
{
Console.WriteLine(" ch " + ch);
}
foreach (mystruct ch2 in tmb2)
{
Console.WriteLine(" tmb 1 " + ch2.kar);
}
/*
for (int i2 = 0;i2<14;i2++)
{
//tmb[i2].kar = str2[i2];
if (tomb[i2] != "empty")
{
//tmb2[i2].kar += tomb[i2];
//tmb[i].kar += tomb[i];
Console.WriteLine(" tmb " + tmb2[i2].kar);
}
}*/
/* */
int i2 = 0;
for (int dt=0;dt<hossz;dt++)
{
foreach (mystruct dt2 in tmb2)
{
i2++;
mystruct mydata = new mystruct();
if (dt2.kar == str1[i2])
{
mydata.a += 1;
tmb2.Add(mydata);
}
}
}
int i3 = -1;
foreach (mystruct rek in tmb2)
{
i3++;
Console.WriteLine(i3 + " elem " + rek.kar + " db " + rek.a);
}
}
}
}