MR. CHIEF JUSTICE BRANTLY
delivered the opinion of the court.
This action was brought against four defendants — B. D., E. L., W. W. and Edythe Purdy — as copartners under the firm name of Purdy Bros., to recover of them the value of work done and material furnished by plaintiff in drilling a well for them under an oral contract. The complaint alleges that the plaintiff agreed on his part to drill the well at a place designated by defendants upon their land or that of some one of them, for the purpose of obtaining water. It then alleges the terms of the contract, how *491and when payment was to be made, and that the plaintiff has fully performed the contract according to its terms, except in so far as he was prevented from doing so by the act of the defendants. It demands judgment for $591.50, less the sum of $21.49, which defendants have paid. The record does not disclose whether the defendants W. W. and Edythe Purdy interposed any defense or whether the action was discontinued as to them. They are not in anywise interested in these appeals. The defendants B. D. and E. L. Purdy joined in an answer which, besides specifically denying the existence of the partnership, denies generally all the allegations of the complaint “except as hereinafter specifically admitted, modified, qualified or denied,” and then interposed a counterclaim for $186.36 for services, team hire, etc., performed and furnished to plaintiff by them as copartners. Upon this counterclaim plaintiff joined issue by reply. The trial resulted in a verdict and judgment for plaintiff in the sum of $503.11 and costs. Defendants have appealed from the judgment and an order denying their motion for a new trial.
1. The first contention made is that the court erred to the [1, 2] prejudice of defendants in ruling that it was not competent for them, under their general denial, to show as a defense that the contract as made by the parties was different in substantial particulars from that alleged in the complaint, and in excluding evidence offered for that purpose. They have presented an elaborate argument, with a citation of numerous authorities, to maintain their position. Technically, the denial as made is not a general denial. (O’Donnell v. City of Butte, 44 Mont. 97, 119 Pac. 281.) Since, however, counsel assume that it is, for the purposes of these appeals we accept their assumption as correct. As an abstract proposition there can be no doubt, either on principle or authority, of the soundness of the rule invoked by counsel. Whatever may be the nature of the cause of action upon which a plaintiff seeks to recover, he must allege in his complaint facts disclosing the presence of all the elements necessary to make it out. (Rev. Codes, sec. 6532; *492Ellinghouse v. Ajax Livestock Co., 51 Mont. 275, L. R. A. 1916D, 836, 152 Pac. 481.) The answer may be a general denial (Rev. Codes, see. 6540), the effect of which is to put in issue every material allegation constituting the cause of action alleged, and thus to cast upon the plaintiff the burden of establishing by his evidence, prima facie at least, the presence of every element of it, and hence his right to recover. If at the close of his evidence he has failed to do this, there is a total failure of proof and he is properly nonsuited. It logically follows that under his general denial the defendant may introduce any evidence which tends to controvert any fact material to plaintiff’s case, and if he is successful in overcoming the prima facie case disclosed by plaintiff’s evidence, as a whole, or in any particular, or in establishing an equipoise in the proof, he is entitled to a verdict. (1 Ency. Pl. & Pr. 817; De Sandro v. Missoula L. & W. Co., 48 Mont. 226, 136 Pac. 711; Stephens v. Conley, 48 Mont. 352, Ann. Cas. 1915D, 958, 138 Pac. 189.) These rules apply to all actions, whatever their nature, for the provisions of the Codes on the subject of pleadings cited supra, furnish the exclusive guide as to what pleadings are required or are permitted in this jurisdiction. As applied to an action on a contract resting in parol, the plaintiff must allege the contract upon which he seeks to recover, a substantial performance of it according to its terms, a breach by the defendant, and the facts showing the amount he is entitled to recover. A general denial by defendant puts in issue all of these allegations. The burden is then cast upon the plaintiff to establish all of them by substantial evidence. If, for instance, he fails to establish the contract alleged, he fails to make out a cause of action (Kalispell Liquor & Tobacco Co. v. McGovern, 33 Mont. 394, 84 Pac. 709), and the defendant is entitled to a nonsuit. So the defendant, under his general denial, may introduce any evidence which tends to show that he did not enter into the contract, or that he made a contract different in one or more substantial particulars from that alleged, or that the plaintiff has failed to fulfill the obligations assumed by him therein accord*493ing to its terms, or any other fact which tends to destroy, not to avoid, the cause of action alleged.
The authorities cited by counsel fully sustain their contention; but they have no application to any ruling made by the court during the trial in this case. Counsel offered no evidence which tended in any way to show that the contract differed in any of its terms from those alleged. Of the several rulings of which they complain, a brief notice of two will be sufficient to show that none of them involved the principle contended for by counsel. Martin Lyden, a witness who had been employed by plaintiff, described somewhat in detail the construction of the well, the measurements of it, the depth to which the water rose in it after it was finished, the kind of casing installed in it, etc. After stating in substance, in reply to questions put to him on cross-examination, that he knew nothing of the terms of the contract, he was asked: “Didn’t you tell Miss Purdy the day before, you came over to put the easing in the well, or the night before, or some few days after the drill-bit was lost, these words: That it was not a good well, that Chealey was going to claim it was, and that he was a hard man to run rip against ? ’ ’ Upon objection by counsel for plaintiff that the question called for evidence that was incompetent and immaterial under any issue made by the pleadings, the witness was not permitted to answer. On direct examination, the defendant B. D. Purdy was asked: “Have you or your brothers or sisters used this well at any time?” The witness was not permitted to answer. There was no prejudice. Neither an affirmative nor a negative answer to either of these questions would have had any value as proof that the contract contained any stipulation other than those alleged in the complaint.
2. The plaintiff testified that he had first had a conversation [3] about drilling the well with B. D. and E. L. Purdy, and had afterward made the contract with B. D. Purdy. He was then permitted to testify over the objection of counsel: “They said they were acting for all of them [defendants]; they were digging it together.” Counsel now contend that this was error *494on the ground that the evidence was hearsay. The ruling was erroneous (Nyhart v. Pennington, 20 Mont. 158, 50 Pac. 413), but could not have prejudiced these defendants. It was alleged by them in their counterclaim that they were copartners. Both admitted in their testimony that they were. The other two defendants who alone could allege prejudice are not parties to these appeals.
Rehearing denied April 13, 1918.
3. The last contention is that the evidence is insufficient to sustain the verdict. The argument is that since the complaint [4] alleges a contract with all four of the Purdys, proof of a contract with B. D. and E. L..Purdy only was such a variance between the allegations of the complaint and the proof that the verdict cannot be sustained. The contention is without merit. It is true, as counsel say, a recovery cannot be sustained against any of several defendants when the contract proven differs substantially from that alleged (Kalispell Liquor & Tobacco Co. v. McGovern, supra); but the fact that a complaint in an action • on a contract alleges a joint contract with several defendants and the evidence discloses a separate contract with some of them is not a variance amounting to a failure of proof within the meaning of section 6587, Revised Codes. (Logan v. Billings & Northern R. Co., 40 Mont. 467, 107 Pac. 415; Rev. Codes, secs. 6711, 6712.)
The judgment and order are affirmed.
Affirmed.
Mr. Justice Sanner and Mr. Justice Holloway concur.