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. C# Enumerable Repeat

C# Enumerable Repeat

Scheduled Pinned Locked Moved C#
csharpjavaandroidtutorialquestion
4 Posts 4 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.
  • P Offline
    P Offline
    Pavlex4
    wrote on last edited by
    #1

    How to do this in Java Android Development?

    var _pass = new string(
    Enumerable.Repeat(_chars, _len)
    .Select(s => s[_rnd.Next(s.Length)])
    .ToArray());

    OriginalGriffO P L 3 Replies Last reply
    0
    • P Pavlex4

      How to do this in Java Android Development?

      var _pass = new string(
      Enumerable.Repeat(_chars, _len)
      .Select(s => s[_rnd.Next(s.Length)])
      .ToArray());

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      First, learn Java. Second, learn C#. Then translate the one to the other. We are not here to do your work for you. And since you are clearly trying to get by without thinking for yourself - your other questions are clear evidence of that - I for one am not prepared to do any more for you. Pull your finger out, learn your subject(s) and start thinking.

      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • P Pavlex4

        How to do this in Java Android Development?

        var _pass = new string(
        Enumerable.Repeat(_chars, _len)
        .Select(s => s[_rnd.Next(s.Length)])
        .ToArray());

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        The best way to translate this is for you to sit down and work out what this code is currently doing. Once you know what this is doing, it becomes a lot easier to translate it into a different language.

        This space for rent

        1 Reply Last reply
        0
        • P Pavlex4

          How to do this in Java Android Development?

          var _pass = new string(
          Enumerable.Repeat(_chars, _len)
          .Select(s => s[_rnd.Next(s.Length)])
          .ToArray());

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          It was always a weird way to do it, certainly took me a minute more time to read than it should. This is particularly offensive since it has a side-effect in code that pretends to be all "pure" and "elegant" and "look at me I'm using enumerables I'm so hip". What it really does is make a string from `_len` random characters from `_chars`, so just implement *that* however makes the most sense. Which in Java is probably this: char[] temp = new char[_len]; for (int i = 0; i < temp.length; i++) temp[i] = _chars[_rnd.nextInt(_chars.length)]; String _pass = String.valueOf(temp);

          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