Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. count words

count words

Scheduled Pinned Locked Moved C#
tutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eyalso
    wrote on last edited by
    #1

    hi i want to count the number of words I have in string (is anybody has code example ) thanks eyalso

    A 1 Reply Last reply
    0
    • E eyalso

      hi i want to count the number of words I have in string (is anybody has code example ) thanks eyalso

      A Offline
      A Offline
      alexey N
      wrote on last edited by
      #2

      Here is the sample: string text = "This is my string"; string[] words = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int countWords = words.Length; Best regards, Alexey.

      E 1 Reply Last reply
      0
      • A alexey N

        Here is the sample: string text = "This is my string"; string[] words = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); int countWords = words.Length; Best regards, Alexey.

        E Offline
        E Offline
        eyalso
        wrote on last edited by
        #3

        I have a problem with " StringSplitOptions" (cant find it) i need to import a class or dll ? eyalso

        A 1 Reply Last reply
        0
        • E eyalso

          I have a problem with " StringSplitOptions" (cant find it) i need to import a class or dll ? eyalso

          A Offline
          A Offline
          alexey N
          wrote on last edited by
          #4

          This enumeration added in framework 2.0. If you're using framework 1.1 use this code: string text = "This is my string"; string[] words = text.Split(new char[1] { ' ' }); int countWords = words.Length; Best regards, Alexey.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups