0
Answer

c# Web Service Dictionary Translator

Henry

Henry

10y
1.2k
1

I'm currently trying to create a simple web service application which will take abbreviations such as, AFK, in textbox1 then when the user clicks the translate button, the program will look up AFK in a .csv excel document I have containing the abbreviations as follows,

Abbreviation.............. Meaning

<3.............. heart

404.............. I haven't a clue

A3.............. Anyplace, anywhere, anytime

ADN.............. Any day now

AFAIK .............. As far as I know

AFK .............. Away from keyboard

So to summarise, there is two text boxes and a button inbetween, when the user clicks the button it should take what they have typed in in textbox1 and translate the abbreviation to the meaning and display the meaning in textbox2.

I've made decent headway with the code but I'm really stumped as to how to progress, any help, hints or tips would be greatly appreciated!

Thanks!

The code I have so far is as follows

[code]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace Tweakspeak_WebService_Coursework
{
    public partial class _Default : System.Web.UI.Page
    {
       
    private Dictionary<string, string> _dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
    protected void Page_Load(object sender, EventArgs e)
    {
        using (var reader = new StreamReader(File.OpenRead(@"J:/TwitterAbbreviations2.csv")))
        {
            while (!reader.EndOfStream)
            {
                string[] tokens = reader.ReadLine().Split(';');
                _dictionary[tokens[0]] = tokens[1];
            }
        }
    }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            localhost.Service obj = new localhost.Service();
            TextBox1.Text = (obj.Translate());
        }

        protected void TextBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}


[/code]