Ketsuekiame 860 Master Poster Featured Poster

If you want to program for MS Windows, and you want a desktop application that's not using something like OpenGL or DirectX, then you really don't want C++. The framework for Windows UI apps in C++ is MFC, which...I don't even want to go there, the nightmares never stop... However, C# is a good intermediate language. Like already said, it's similar in syntax to Java with subtle differences but you should pick those up fine.

If you want to write automation utilities, services, underlying libraries where performance is more important than productivity, C++ is the right tool for the job. If you want to program for Linux, again C++ is probably the wrong choice (python and GTK+ is probably the right choice). Don't use a programming language because you think it's more powerful, or has better control unless you need it. Nowadays there are so many options it's more about using the right tool for the job.

Ketsuekiame 860 Master Poster Featured Poster

IE != Visual Studio browser control. It's a very thin shim only really used for rendering pure HTML. If you want more advanced functionality I would look at using WebKit or Chromium.

Ketsuekiame 860 Master Poster Featured Poster

Make sure you're running it in Debug mode. In Release this could have been optimised away because you're not using the variable.

ddanbe commented: Great! +15
Ketsuekiame 860 Master Poster Featured Poster

If you have an image in code then you should be able to get the byte array out of the object that contains the data. It might be called GetBytes() or something. In any case, look for a method which will give you a byte array.

I also noticed that you specified a length of 50 bytes. That's not going to be enough to store a decently sized image. Try 2Mb instead. That will let you have a JPEG of decent size.

To store, you pass the byte array of the image data as the Value of that parameter.

Ketsuekiame 860 Master Poster Featured Poster

Have a try at doing it first. If you enjoy it then there's no problem! Right? :)

If you get stuck come back with what you've done and what your specific problem is. Then we can help. Doing your work for you is cheating at best and plagiarism at the worst. Neither of which are good for you as a learner ;)

ddanbe commented: Nice +15
ChrisHunter commented: diplomatic response +7
Ketsuekiame 860 Master Poster Featured Poster

In C# you can think of all classes as references (pointers)

Like ddanbe said above, if you really want the pointer, you can use the unsafe keyword and then use it like C++. A more safe way is to marshall it out into an IntPtr object, but this is generally reserved for interop (Win32 API) code.

Given that your code looks to be self-contained you don't need the actual pointer reference.

Quick overview:

Nearly all objects are of two basic types; value and reference. A reference type can be treated almost identically to the pointer type in C++ and value types are the same as normal definitions and primitives (such as int, float, long CMyClass)
A quick easy rule as to whether something is a value type or reference type;
structs are value types and classes are reference types.

You can also say that anything that inherits Object is also a reference type but there are special rules around this too (such as boxing and unboxing).

To make it relevant to your code:

List<CAccount> list = new List<CAccount>(); in C# is the equivalent of
std::vector<CAccount*> list; in C++

ddanbe commented: Could not have explained it better. +15
Ketsuekiame 860 Master Poster Featured Poster

If you don't want to be able to "read" your serialised list, or to be able to import from a common format, don't use XML. It can be quite slow once you get into large amounts of objects.

Have you considered using SQL Express? That way you can have a "LocalDB" that is deployed with your application and can be used to store your data. It might also be worth looking at Document Databases for something like this. A local store is small, powerful and can be updated in real-time. Using file based storage, this would be tricky (but possible, leading to a lot of disk IO)

ddanbe commented: Good advise +15
Ketsuekiame 860 Master Poster Featured Poster

There's a couple of ways.

As well as using TLS (standard SSL solution) you can also use Certificate based authentication (effectively enforcing that both client and server have valid certificates)

You can also use Username and Password based authentication (including domain authentication if you have that available)

The easiest, if you ask me, is using certificates in a Client/Server auth process. As you're using Server-Server communication, I would recommend this.

Additionally, if you're worried about MITM attacks, you can encrypt and sign your messages in addition to the transport.

I should point out that client/server cert authentication is pretty easy to set up so don't let the idea of using certificates put you off.

Ketsuekiame 860 Master Poster Featured Poster

You need to add it as an application in IIS. If you upload the code files using FTP, you can use IIS Manager to add the WCF application (as an application) to your website.

Note that you must have the HTTP Activation Service enabled on your server in order for this to work.

Ketsuekiame 860 Master Poster Featured Poster

Aggregate is incredibly useful. As an explanation to Chris, Aggregate takes the result of the function and passes it as the parameter into the next iteration of the function. This makes it possible to create an aggregate of data from your list (hence the function name) :)

Ketsuekiame 860 Master Poster Featured Poster

You could use

Custom item = data.OrderByDescending(obj => obj.Index).FirstOrDefault();

Does the same thing but looks tidier :)

Ketsuekiame 860 Master Poster Featured Poster

Ok. I was going to do that as a last resort since multiple people might connect at once and mix up the names. Thanks anyway.

You can't. Data comes down each socket from a specific client (unless you're using Broadcast). So if you keep that socket in a particular method that expects a certain "Initialisation" data, then there's no chance of mixing names up.

Ketsuekiame 860 Master Poster Featured Poster

Depends what you're talking about (again). Unfortunately there are two meanings for "4K".

One is the industry standard, 4096x2160 and the other is UHDTV which is 3840x2160. I will continue to assume 4K means 3840x2160 as this is what monitors and TV broadcasts will be.

Assuming that you're watching on a standard TV at 24fps a 10bpp RAW, video only, 4K video will consume ~79.1MB/frame or ~1898.44MB/sec.

H.264 can achieve a compression ratio of approximately 64% (ref)

For the purpose of mathematics, we will assume that this is the average of all frames and therefore, that every frame produces the same compression ratio.
This means that with HEVC, 4K will consume approximately 683.44MB/sec

Hope this helps.

EDIT: This calculated ratio is somewhat better than the first movie available in 4K which was 160GB for 129seconds

Ketsuekiame 860 Master Poster Featured Poster

You can use a Binding Converter to get what you need. It will allow you to do pretty much anything to the data before it is used.

Very useful, very powerful and not too hard to get the hang of :)

Ketsuekiame 860 Master Poster Featured Poster

Not sure if it's just me but the home page doesn't work. It's just presenting the background colour but no content.

The following is received by the browser:

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en-US" lang="en-US">
<head>
    <!-- CSS -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400" />
    <link rel="stylesheet" type="text/css" href="/articles/article_css/nogroup4637896363" />
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!-- Javascript -->
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="/articles/js_article_scripts/nogroup995122999598"></script>   
    <script type="text/javascript">

    // Add a script element as a child of the body
    function downloadJSAtOnload() {
        var element = document.createElement("script");
        element.src = "/articles/js_deferred_scripts/nogroup109951229995600";
        document.body.appendChild(element);
    }

    // Check for browser support of event handling capability
    if (window.addEventListener)
        window.addEventListener("load", downloadJSAtOnload, false);
    else if (window.attachEvent)
        window.attachEvent("onload", downloadJSAtOnload);
    else window.onload = downloadJSAtOnload;    
    </script>    

    <!-- CSRF Hash -->
            <script type="text/javascript">var csrf_hash = '08a7741386e2c74267869908dd0a5bb0';</script>

    <!-- Microdata -->
    <meta property="og:site_name" content="DaniWeb" />
    <meta property="og:image" content="http://static.daniweb.com/images/icon.png" />
    <link rel="image_src" type="image/png" href="http://static.daniweb.com/images/icon.png" />
    <meta property="fb:admins" content="509930074" />
    <link href="https://plus.google.com/+DaniWebCommunity" rel="publisher" />

            <link rel="home" href="http://www.daniweb.com/" />   
        <link rel="search" href="http://www.daniweb.com/search/query" />


    <!-- Google Analytics -->
        <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-98289-1']);
      _gaq.push(['_trackPageview']);
      _gaq.push(['_trackPageLoadTime']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

    </script>    

You can get on the site by navigating to a sub-forum directly.

Ketsuekiame 860 Master Poster Featured Poster

If the host doesn't have any documentation, find another host. If you pay for a simple development website that uses ASP.NET, they often come with database hosting. i realise you're looking for free but they can have some rather aggressive limitations.

Connecting to a SQL instance is done via ConnectionStrings. This site is good for figuring out connection strings. Typically you need the server address and the Instance name. You then treat it exactly as you would the local one, although expect latency.

Ketsuekiame 860 Master Poster Featured Poster

Well, your two options are (to achieve what you want);
1. Decode the PDF server side and parse into HTML format. Insert that between your div
2. Run some kind of Java Applet that requests the file from your database. That file would still need to download to the client machine, but would only exist in the applet's memory. You could then stream that to wherever you want. If you want it in your div, then you need to parse it to HTML again.

Ketsuekiame 860 Master Poster Featured Poster

Probably better asking on Business Exchange. You're essentially asking us to pitch business ideas at you. ;)

Ketsuekiame 860 Master Poster Featured Poster

Nothing really, they both have the same outcome. The second way is the preferred method if you know the contents before hand.

It boils down to;

Guy[] guys = new Guy[3]; -- You're reserving space for 3 "Guy" objects in this array. You don't yet know what object is going where, this will be filled in later.
Essentially guys[0 to 2] == null

Guy[] guys =
    new Guy[3]
    {
        new Guy { Name="Joe", Cash=50, MyRadioButton=rbGuy1, MyLabel=lblBetDesc1 },
        new Guy { Name="Bob", Cash=75, MyRadioButton=rbGuy2, MyLabel=lblBetDesc2 },
        new Guy { Name="Al", Cash=45, MyRadioButton=rbGuy3, MyLabel=lblBetDesc3 }
    };

I'm initialising the array with these three objects. Seeing as we already know the contents, there's no point reserving space and then filling it in later.

If you were going to do your method 1, the compiler would probably optimise it away so that the array is initialised with the contents on the next three lines (although I can't guarantee).

So, use method 1 when you're filling array contents from a different source or you don't have the contents yet.
Use method 2 when you already know which objects are going to be used.

Ketsuekiame 860 Master Poster Featured Poster

Hmm, I wouldn't remove on a simple edit.
I would put a little button on your profile page that clears the flag.

I've always prefered explicit over implicit, especially in cases like this. :)

Ketsuekiame 860 Master Poster Featured Poster

You won't be able to do this entirely in C# unless you utilise something like SharpDX.

You will need to call out to a C++ library in all liklihood.

Once you have the stream, you can display it on a form. A picture box might not be the best control for this, but it totally depends on how the video data is streamed to you (for example, you might have a WMV stream rather than an array of bitmaps etc)

Ketsuekiame 860 Master Poster Featured Poster

Ah, sorry I'm used to dealing with Sockets and not the TcpClient abstraction. Calling close on the TcpClient should be enough.

You could try switching to MessageReader.ReadBytes. The advantage here being that it will read all the data available up to the size you specify, if available. This call will not block, but instead will return how many bytes it managed to read on this operation. If the stream has closed (reached the end) it will return -1. You can check for this value to tell you whether or not the stream has closed.

Also, becareful with your message parsing loop. You will get stuck in an infinite loop there if an exception is never thrown.

Ketsuekiame 860 Master Poster Featured Poster

According to specification, a TCP/IP connection has no requirement to idle timeout.
You're now essentially saying "I'm expecting data to be received within 20 seconds, otherwise, something went wrong."

The OS or network card itself will handle the underlying connection when this happens and in some cases could take this to mean "The connection has been lost" and close it.

You have two solutions;

  1. Remove the timeout, there's no need for one unless you're expecting data every x [milli]seconds. To remove the problem of threads not joining because of the read block, Shutdown <--- IMPORTANT and Close the socket before you try to join. This will cause the Receive method to abort and throw an exception. A little bit dirty, but within spec.

  2. Sending a simple "PING-PONG" every x seconds that goes by without a data-send, for example, would be sufficient to keep the connection open without worrying about the timeouts.

I would personally go with option 1. Option 2 can get complicated even though it may seem simple at first.

Ketsuekiame 860 Master Poster Featured Poster

Depends what you mean by interactive!

Technically an accounting program is interactive, but often that's not what people mean :)

But a simple yet fun project...How about creating a multiplayer (keyboard sharing) game of Battleship?

The rules are simple, it's sufficiently easy to design and implement, yet complex enough to stretch some of your initial skill set. I also presents room for modification later as your skills improve (such as networked multiplayer or increased number of players etc)

Ketsuekiame 860 Master Poster Featured Poster

You should probably copyright from the first registered date to the current date, especially as Dani has made changes to both the UI and the API this year.

I'm not sure how it works in the US but in the UK and EU typically you would include the start and end date of something as dynamic as a web system, to ensure that you protect your future iterations. Your registration would cover a number of years (typically 5) before you needed to re-register your copyrighted works.

Ketsuekiame 860 Master Poster Featured Poster

Lists aren't pre-defined. You have to add and remove from them (unless you give themn an initial size).

So if you do;

List<int> myList = new List<int>();
myList[3] = 12;

This will fail. Having an empty list is a bit like having an array of 0 length.

To actually have index 3 set to 12, you would need to do

// this inserts three entries into the list
List<int> myList = new List<int>() {0, 0, 0, 12};

When you initialise an array to a particular size, you're actually pre-filling it with the default for that object.

Doing;

int[] myInts = new int[4]();

Could be considered equivalent to;

// The 4 in the constructor tells C# my initial list size will be 4 objects. It isn't necessary.
List<int> myInts = new List<int>(4) { default(int), default(int), default(int), default(int) };

To answer your original question; a List<List<T>> will do what you want. But remember that you can't set arbitrary locations. If you want to do that, you may need ArrayList or to redefine your arrays and copy the data across.

A better design, in my opinion. Would be to use proper objects.

public class MyDataColumn
{
    public int Index
    {get;set;}

    public string ShortName
    {get;set;}

    pubic Type DataType
    {get;set;}
}

...

public class MyDataItem
{
    public int RowNumber
    {get;set;}

    public MyDataColumn AssociatedColumn
    {get;set;}

    public object Data
    {get;set;}
}

...

List<MyDataItem> dataItems;

etc.

It's harder to set up the databinding and there's a bit more …

ddanbe commented: Great knowledge! +15
Ketsuekiame 860 Master Poster Featured Poster

Because people don't want to pay for anything.

You go on a mobile store, want to find a game. Oh this costs 20p??? I'm not paying for it! People will download a game for free, get drawn in and then need to spend money on it. This is the driving motivation. "I'm not paying for a game" yet "I need to pay to complete this level. PLX TAKE ALL MY MONEY!"

I find it incredibly annoying. But, the common user has driven the market this way...

Ketsuekiame 860 Master Poster Featured Poster

If you don't add it to source control it will still exist on disk. Part of the build process, though, will be to copy your localdb to the correct location.

If you add your local db as a file in your project, then set it as "Copy to Output path" it should copy it to your Debug/Release folder when you build.

If you're using VS Online, do you have Azure? Set up a small SQL Web server and use that during development. Once you've finished development, you can copy the schma, seed your localdb and deploy as normal.

Ketsuekiame 860 Master Poster Featured Poster

IIS tends to ignore those settings. Why? Who knows... However, it will pull them from the AppConfig if you set them.

<add key="loginUrl" value="~/login/" />
<add key="defaultUrl" value="~/unauthorized/" />

If you add those into your config, it should work.

Ketsuekiame 860 Master Poster Featured Poster

It depends how you use the data. If you want to do index and searching, the database is going to be far better at it. This comes at the expense that your data is (marginally) harder to read and edit.

If your objects are going to be loaded and cached, XML is going to be better as it's easier to read and edit. This comes at the expense of poorer performance as you will need to parse the XML. Also, if you're going to cache it all, I hope the target system has enough RAM :)

Personally, I wouldn't use XML for anything other than basic configuration and data serialisation for transmission (on small objects of a couple of Mb max, otherwise custom Binary serialisation)

Ketsuekiame 860 Master Poster Featured Poster

Essentially yes, break down your code into tasks that you can run in a method. You can give the background worker a method to execute (that's all a delegate is) and run it that way.

Be careful about altering UI components. That has to be done on the Main thread and you can easily lock your UI up that way.

A better suggestion might be to look at the Task namespace and the async keyword.

I'd also look at your design and split code into Data Load/Data Process/Date Presentation rather than having a single method do all the work.

ddanbe commented: Excellent advise +15
Ketsuekiame 860 Master Poster Featured Poster

As a note, you should also wrap the command in a using statement too ;)

Mike Askew commented: Not my code :D +7
Ketsuekiame 860 Master Poster Featured Poster

If EnumerateDirectories ends after trying to access a directory it cannot then you're going to need to create your own search function.

EnumerateDirectories will give you all the directory names for the folder it is currently searching. With the AllDirectories flag it will search all sub directories as well. Your exception will be raised when it tries to enter a sub-directory it doesn't have permission to do so, in this case, you're going to have to re-implement this behaviour yourself.

Retrieve a list of the directories at the current level, then one by one enter the sub-directories. When you hit one you can't enter, just skip it and move to the next.

Ketsuekiame 860 Master Poster Featured Poster

Ketsuekiame:
It seems that you dont understand what the thread starter is asking.

What he wants is when selectedvalue does not exist in the list of items he want the selectedindex = 0 or selectedvalue is "-- Select --".

So the best way to do that is:

Before fetching a data from the database do this:

ComboBox1.Items.Add("-- Select --");
Fetch the data from the database.
No data from database then, ComboBox1.SelectedIndex = 0;
Simple,am I right?

I understood perfectly what he said; unfortunately your solution isn't viable as the OP is using databinding. You cannot modify the list after it is bound. So, the only way would be to insert it into the data items before the control gets bound.

The other problem with your method is that you're treating a valid selection as in in-valid one. An index of 0 is a perfectly valid selection. If you're trying to deselect an item, you must set the SelectedIndex to -1.

From the MSDN:

To deselect the currently selected item, set the SelectedIndex to -1.

This unsets the selected item and invalidates the control. The fact that the control is no longer valid is important is ASP.NET validation.

Unfortunately, my way doesn't work either. As the list is databound, you cannot set the Text property of the ComboBox. It is unset (reset) and made read-only.

The only way to get what the OP wants, is to dirty the actual data, or simply pre-process …

Mike Askew commented: This +7
Ketsuekiame 860 Master Poster Featured Poster

No it is a bug. This Hotfix should work

Unfortunately, it means that you need to include this hotfix with your application redist.

Edit: Reading the bug report there is a workaround - Add the style as a dynamic resource reference or add it as a static resource to the xaml resource dictionary.

ddanbe commented: Whish I had this WPF knowledge +15
Ketsuekiame 860 Master Poster Featured Poster

Firstly, although MyClass inherits IComparable the compiler doesn't know that it can be converted (sometimes the compiler is dumb). If you change your original definition from MyClass[] mine = new MyClass[5] to IComparible[] mine = new MyClass[5] that will be fine.

Finally, you can only pass an assignable value with the explicit ref keyword. new MyClass(8) isn't assignable, you would need to put this into a variable first and then pass it through.

Strictly speaking, however, you can drop the ref keyword. Your object is being passed by reference anyway.

For Completeness:

When you pass an array into a method, you're passing the pointer to it by value. What this means is that any changes to the contents of the array will be reflected in the original object, however, re-assigning the array will not. That's why you needed the ref keyword. You don't need the ref keyword on the second parameter as it is already passed by reference.

Ketsuekiame 860 Master Poster Featured Poster

Here's something for you deceptikon. Relating to evolution, life and consciousness.

What is the purpose of death? Is it an evolutionary trait? If so, why? What is the point of evolution (which is supposed to keep the species alive), the struggle of life, if it ends with death?
Life tries to live. It tries to stay alive. Breeding helps keep the species alive, but for what purpose? Why does life try to beget life when all it does is die? Seems pretty pointless if you ask me... (Not trying to be depressive here)

So, what if life as a whole is simply trying to exist? What if individuality as we understand it is simply wrong and all these processes of evolution and the struggle to procreate are simply to keep "life" in existence, regardless of what it is that's alive.
The problem I have is that I fail to understand what the goal of this cycle is. To merely keep going? If so, keep what going? I guess this is the question "What is the meaning of life?"

On another level, things get really freaky when you consider looking at whether or not it was possible to have not existed.
My reasoning here is that the fact that you are conscious was impossible to have not happened. Unfortunately it means dealing with infinites, so mathematics won't help. However, if we consider logic, given that when unconcious there is no perception of time. If nothing is concious, abstractly, …

Reverend Jim commented: Interesting discussion. +0
Ketsuekiame 860 Master Poster Featured Poster

Please copy and paste the error you're getting.

KushMishra commented: good question and meant for all when asking questions like this +2
Ketsuekiame 860 Master Poster Featured Poster

Was that a challenge? ;)

EDIT:

Done :)

using Common;
using System;
using System.Collections.Generic;
using System.Linq;

namespace StringSplitTest
{
    public class MainClass : IExecutionClass
    {
        const string str = "abc,123.xyz;praise;end,file,clear";
        public bool Execute(params object[] programData)
        {
            SplitStringByNonAlphanumerics(str).ForEach((s) => Console.WriteLine(s));

            return true;
        }

        public List<string> SplitStringByNonAlphanumerics(string stringToSplit)
        {
            return stringToSplit.Split(stringToSplit.Where(c => !char.IsLetterOrDigit(c), StringSplitOptions.RemoveEmptyEntries).ToArray()).ToList();
        }
    }
}

Note: The Common library contains interfaces for my test framework and the usage here is so I could inherit the IExecutionClass

Everything else is included in the standard framework.

ddanbe commented: Nice! +14
Ketsuekiame 860 Master Poster Featured Poster

Because it's the unofficial global calendar and not using it would just make things unnecessarily complicated.

Just because someone of faith does something, does not mean an Atheist must not do that something.

Additionally, the Chinese use a lunisolar calendar in a civil capacity (for special social events) as I believe this used to be the national calendar. They did not follow a western religion and so had no exposure to the Gregorian calendar. However, in modern day they do use the Gregorian calendar for business purposes.

In England, the national calendar is the Gregorian calendar. England itself, or America for that matter are countries of faith. Going against the national standard, just because an Atheist doesn't share their belief with, for example Christianity, is illogical.

I also fail to understand why the sudden pop at Atheism when, as far as I can tell, no one has taken a shot at any other belief in this thread.

Ketsuekiame 860 Master Poster Featured Poster

You'll need three at the minimum, five seems like a decent basic design.

CustomerDetails - Store the basic customer details.
Jobs - A record of each and every job undertaken.
CustomerJobs - A link between a customer and any job undertaken for that customer.

Optional:
JobStatus - Small definition table that gives the different states a job can be in.
Departments - A record of each department in the college. This will be linked from CustomerDetails. (This is better design that simply entering a text field)

What you need to remember when designing your database is not to over-fill tables with unnecessary information. Remember the responsibility principle used in Software Engineering as the same methodology can be used for database design.

Ketsuekiame 860 Master Poster Featured Poster

Probably better to use an enum and to mark the tag with the enum, that way you can use a single method to find and activate the correct tab.

Less messy than using a switch statement.

Ketsuekiame 860 Master Poster Featured Poster

Okay, so the Enumerable.Range(start, count) generates a sequence of numbers. When you do the select on this it will perform the lambda of the select for each number in the sequence. I'm not really that interested in the number that the Enumerable outputs, that's a means to an end. This is because, as we know already, the sequence can be nicely calculated using a series of 1s squared.

The string constructor allows you to tell it to repeat a character x amount of times. The lambda, is essentially building the sequence of "1" for me. A common misconception with LINQ is that you have to get out what you put in, but this isn't true. So I put in an integer (3 for example) and get out a string (for 3 would be "111")

The Select method builds a new List of strings for me.

Unfortunately, you can't make Enumerable.Range count down, I tried experimenting with TakeWhile but simply using .Reverse().Select() gave better output, simpler. So to join the two currently non-existent lists together I had to use Concat. If you were to execute this query now, you'd get a list out that looked like

"1"
"11"
"111"
"1111"
"11111"
"1111"
"111"
"11"
"1"

So now we have the string of 1s that can be used for the calculation. As the easiest way to generate them was as strings, they needed to be parsed back to int so I could work on them mathematically, so input list of …

Ketsuekiame 860 Master Poster Featured Poster

I doubt the fan is causing the issue. The four pin fan leads allow you to use PWM to regulate the fan speed. You could always unplug it completely, if it's the CPU fan the CMOS will beep to tell you the CPU fan is unplugged, it shouldn't shut down.

As you're not passing CMOS, it sounds like there is an issue either with your RAM or CPU. Additionally, as this is a "gaming" machine that you won at a LAN, chances are it's overclocked and the machine may now just be too old to run that configuration (or is now sufferring from voltage burn)

Reset the CMOS and if that doesn't fix it immediately, pull out all the RAM, then test them one at a time. I would leave the machine running for at least one day, or until your first power off, for each stick of RAM.

If this still does not correct the issue, try and find someone who's components are compatible with your own and test theirs in your system. If this doesn't work, it's likely your motherboard is dead. Test each of your components in your friend's system. If they are all fine, you need to replace the motherboard.

If at the end you haven't isolated the issue, sell all the components you know work on eBay and buy a new machine.

Ketsuekiame 860 Master Poster Featured Poster

I cheated slightly...But here's a one liner :)

using System;
using System.Linq;

namespace OneLineTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Enumerable.Range(1,5).Select(x => new string('1', x)).Concat(Enumerable.Range(1,4).Reverse().Select(x => new string('1', x))).Select(int.Parse).ToList().ForEach(y => Console.WriteLine("{0,9}", y*y));
            Console.ReadKey();
        }
    }
}

It could probably be optimised and I don't like the nesting but I can't recurse without defining a function so I picked the lesser of two evils.

I've been trying to find a way that I didn't have to do a mid level concat and parse but I think that my knowledge of LINQ is too limited.

ddanbe commented: Knowledge of LINQ too limited? :) +15
Ketsuekiame 860 Master Poster Featured Poster

I've had some success, 3 statements is my smallest but still not a single one. I will continue this afternoon, I can feel it wanting to escape my brain ;)

So far my method VERY closely matches ddanbe's (one of the best things about this is being able to calculate the next line based on the previous, it removes a lot of the looping you guys are doing)

I can't really get away with spending all day at work doing this and not getting any actual work done...So can't really work on it atm, but I think I should have the answer tonight :)

castajiz_2 commented: i can t wait to see your code, though i don t want to put any pressure, just post it when you r done with it +3
Ketsuekiame 860 Master Poster Featured Poster

No no, I haven't done it on one line, but I think it should be possible. It was a thought challenge :)

Mike Askew commented: Please deliver, we await. +7
Ketsuekiame 860 Master Poster Featured Poster

Thinking about it, I believe this might be possible in a single statement. Bonus points if you can do it...

Ketsuekiame 860 Master Poster Featured Poster

The hint here is that you need to draw a flow chart. Rather than thinking of a straight line, you will need to break off and create two parallel flows.

Imagine you're standing in line at the coffee shop, the first thing the cashier asks is "What would you like?" In this case you have two options, tea or coffee. So you choose Coffee and the cashier inputs that on their till. This has started the "Coffee" flow. Then they will ask, "Would you like any extras such as Ice or Cream?" if you say "Ice", they then might ask "Would you like it blended?" All this while they're inputting your answers into the till which is totting up the total. At the end they ask "Would you like anything else?" Which begins the process again.

You need to apply this logic to your application. If you're struggling with the concept in code, I guarantee you will find it much easier to write the flow down first and write the code based on the flow.

ddanbe commented: Very good advice +15
Ketsuekiame 860 Master Poster Featured Poster

You can have a fillet steak for dessert, right? ... Right?? :S

On a serious note, warm chocolate cake, with chocolate sauce inside with cornish ice cream on the side drools

ChrisHunter commented: ANY time is steak time! +0