10 Replies - 922 Views - Last Post: 18 December 2014 - 09:48 PM Rate Topic: -----

#1 TaLeNT   User is offline

  • D.I.C Head

Reputation: -8
  • View blog
  • Posts: 122
  • Joined: 05-September 14

Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 08:51 AM

Hey everyone,

I was wondering if this was even possible and if so, how do I do it.

else if (speech.ToLower().Contains("truck") && speech.EndsWith(number))
                   {

                       Here I would like to see if my speech had ended with any of the values i would have stored in the
string "numbers". If it did, I would like to just take the value and add it to a new string called whatever


                   }




I have tried this a million different ways and I cant get it to work. I'm not even sure how I would go about storing tons of different numbers in one string, or if that's even possible.

Is This A Good Question/Topic? 0
  • +

Replies To: Making a string Equal many different values, then compare those values

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,187
  • Joined: 12-June 08

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 08:57 AM

How about you give an example since what you wrote in line 4 and 5 did not make much sense.
Was This Post Helpful? 0
  • +
  • -

#3 rgfirefly24   User is offline

  • D.I.C Lover
  • member icon


Reputation: 466
  • View blog
  • Posts: 2,212
  • Joined: 07-April 08

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 08:58 AM

Why in the world would you want to do that when there are Collections that do it so much better.

I would create a List<int> and store the numbers in there. If your insistent though that you want to go with the bad design and store them in a string then you can use string concatenation to do it: whatever += number.ToString();. Please though rethink what your doing as this is very bad design.
Was This Post Helpful? 1
  • +
  • -

#4 TaLeNT   User is offline

  • D.I.C Head

Reputation: -8
  • View blog
  • Posts: 122
  • Joined: 05-September 14

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 09:01 AM

View Postrgfirefly24, on 18 December 2014 - 08:58 AM, said:

Why in the world would you want to do that when there are Collections that do it so much better.

I would create a List<int> and store the numbers in there. If your insistent though that you want to go with the bad design and store them in a string then you can use string concatenation to do it: whatever += number.ToString();. Please though rethink what your doing as this is very bad design.



Would I be able to store about 50 different 4 digit numbers in the same list<int>?

Like it would be "Numbers" and that int would equal 8145, 9912, 1012, and so on..

I'm finding it very hard to make sense of this too "modi" I dont really understand how to explain myself here, Sorry.

This post has been edited by TaLeNT: 18 December 2014 - 09:02 AM

Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 09:06 AM

The "else if" part of what I see also worries me. I'm going to guess this is some sort of speech recognition dream filled with dozens or hundreds of

// I want to create the Ironman house computer
if (speech.contains("Jarvis")
{
    if (speech.contains("this phrase"))
...
    else if (speech.contains("that phrase"))
...
    else // 100 else if later

Was This Post Helpful? 0
  • +
  • -

#6 TaLeNT   User is offline

  • D.I.C Head

Reputation: -8
  • View blog
  • Posts: 122
  • Joined: 05-September 14

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 09:14 AM

View PosttlhIn`toq, on 18 December 2014 - 09:06 AM, said:

The "else if" part of what I see also worries me. I'm going to guess this is some sort of speech recognition dream filled with dozens or hundreds of

// I want to create the Ironman house computer
if (speech.contains("Jarvis")
{
    if (speech.contains("this phrase"))
...
    else if (speech.contains("that phrase"))
...
    else // 100 else if later



Da'Aww, you being a douche is really cute.

It's nice to come on forums asking a legit question only to get the sarcastic, rude people to say things the don't even revolve around the question just to seem "Cool"

First, It is obviously some sort of of speech recognition(Hence the speech.contains -_-/>/>/>)
Second, Just because its speech recognition does not mean it has anything to do with some lame movie. I'm trying to create an inventory structure for my business. I've already got it done flawlessly by a database and now I thought it would be cool to search my records by voice instead of having to be physically at the computer typing it in.
i.e
I can be physically searching through inventory while asking info about my merchandise.

Thank you though, Your' lame ass answer was extremely helpful.

This post has been edited by TaLeNT: 18 December 2014 - 09:17 AM

Was This Post Helpful? -6
  • +
  • -

#7 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,187
  • Joined: 12-June 08

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 09:28 AM

Dial it back there TaLeNT. It didn't sound like there were any specific barbs to take umbrage with.
Was This Post Helpful? 0
  • +
  • -

#8 TaLeNT   User is offline

  • D.I.C Head

Reputation: -8
  • View blog
  • Posts: 122
  • Joined: 05-September 14

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 09:32 AM

View Postmodi123_1, on 18 December 2014 - 09:28 AM, said:

Dial it back there TaLeNT. It didn't sound like there were any specific barbs to take umbrage with.



Maybe I came back a tad bit strong but honestly, writing a response on my post just to "mock" what I'm trying to achieve is wrong and extremely annoying.
That's the kind of stuff that should not be allowed to happen.

Either way, Ok I will.

This post has been edited by TaLeNT: 18 December 2014 - 09:33 AM

Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,187
  • Joined: 12-June 08

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 09:35 AM

Again - I don't think he was mocking you, but stating a common concern over what has been seen popup in similar threads.

Honestly - up until his post I still had nary a clue on what you are trying to accomplish.
Was This Post Helpful? 0
  • +
  • -

#10 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 09:38 AM

Quote

I'm trying to create an inventory structure for my business.


Ok. As already asked, do you understand Collections in C#? It would be virtually impossible to create an inventory system without them. But your approach of putting "tons of numbers in a string" would make most of us think you are unfamiliar with collections.

So help us to help you... by helping us understand your knowledge level before going further. It would also help TREMENDOUSLY if you could share with us some of your design concepts for this inventory program: For example, what database, have you worked out your object architecture yet, WinForms or WPF, are you hand-coding all the database interaction or are you using Entity Framework or LLBLgen or some other ORM... ?
Was This Post Helpful? 0
  • +
  • -

#11 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7056
  • View blog
  • Posts: 23,989
  • Joined: 05-May 12

Re: Making a string Equal many different values, then compare those values

Posted 18 December 2014 - 09:48 PM

There is a major flaw in your comparison method as well. Consider the following statement that would satisfy your conditions: "I was star-struck watching the movie 1941". It satisfies the condition Contains("truck"), and that it ends with a 4 digit number.

If I had to tackle this, I would use a regular expression to try to match the pattern I was looking for, but only if the speech or text followed rigid rules in their possible forms.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1